From c8f0491fd65436a5aa1e9e742d84c9f3490cb4dc Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Tue, 21 Mar 2017 17:28:03 +0800 Subject: [PATCH 1/2] update --- demo/formula.js | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 demo/formula.js diff --git a/demo/formula.js b/demo/formula.js new file mode 100644 index 000000000..291d71cca --- /dev/null +++ b/demo/formula.js @@ -0,0 +1,5 @@ +/** + * Created by User on 2017/3/21. + */ +FormulaCollections = ["abs","ABS","acos","ACOS","acosh","ACOSH","add2array","ADD2ARRAY","and","AND","array","ARRAY","asin","ASIN","asinh","ASINH","atan","ATAN","atan2","ATAN2","atanh","ATANH","average","AVERAGE","bitnot","BITNOT","bitoperation","BITOPERATION","ceiling","CEILING","char","CHAR","circular","CIRCULAR","class","CLASS","cnmoney","CNMONEY","code","CODE","col","COL","colcount","COLCOUNT","colname","COLNAME","combin","COMBIN","concatenate","CONCATENATE","correl","CORREL","cos","COS","cosh","COSH","count","COUNT","crosslayertotal","CROSSLAYERTOTAL","date","DATE","datedelta","DATEDELTA","datedif","DATEDIF","dateinmonth","DATEINMONTH","dateinquarter","DATEINQUARTER","dateinweek","DATEINWEEK","dateinyear","DATEINYEAR","datesubdate","DATESUBDATE","datetime","DATETIME","datetonumber","DATETONUMBER","day","DAY","days360","DAYS360","daysofmonth","DAYSOFMONTH","daysofquarter","DAYSOFQUARTER","daysofyear","DAYSOFYEAR","dayvalue","DAYVALUE","decimal","DECIMAL","decode","DECODE","degrees","DEGREES","encode","ENCODE","endwith","ENDWITH","enmoney","ENMONEY","ennumber","ENNUMBER","eval","EVAL","even","EVEN","exact","EXACT","exp","EXP","fact","FACT","fields","FIELDS","filename","FILENAME","filesize","FILESIZE","filetype","FILETYPE","find","FIND","floor","FLOOR","format","FORMAT","getuserdepartments","GETUSERDEPARTMENTS","getuserjobtitles","GETUSERJOBTITLES","greparray","GREPARRAY","hierarchy","HIERARCHY","hour","HOUR","i18n","I18N","if","IF","inarray","INARRAY","index","INDEX","indexof","INDEXOF","indexofarray","INDEXOFARRAY","int","INT","isnull","ISNULL","joinarray","JOINARRAY","jvm","JVM","layertotal","LAYERTOTAL","left","LEFT","len","LEN","let","LET","ln","LN","log","LOG","log10","LOG10","lower","LOWER","lunar","LUNAR","map","MAP","maparray","MAPARRAY","max","MAX","median","MEDIAN","mid","MID","min","MIN","minute","MINUTE","mod","MOD","mom","MOM","month","MONTH","monthdelta","MONTHDELTA","now","NOW","numto","NUMTO","nvl","NVL","odd","ODD","or","OR","pi","PI","power","POWER","product","PRODUCT","promotion","PROMOTION","proper","PROPER","proportion","PROPORTION","radians","RADIANS","rand","RAND","randbetween","RANDBETWEEN","range","RANGE","rank","RANK","records","RECORDS","regexp","REGEXP","removearray","REMOVEARRAY","repeat","REPEAT","replace","REPLACE","reverse","REVERSE","reversearray","REVERSEARRAY","right","RIGHT","round","ROUND","round5","ROUND5","rounddown","ROUNDDOWN","roundup","ROUNDUP","row","ROW","rowcount","ROWCOUNT","second","SECOND","seq","SEQ","sign","SIGN","sin","SIN","sinh","SINH","slicearray","SLICEARRAY","sort","SORT","sortarray","SORTARRAY","split","SPLIT","sql","SQL","sqrt","SQRT","startwith","STARTWITH","stdev","STDEV","substitute","SUBSTITUTE","sum","SUM","sumsq","SUMSQ","switch","SWITCH","tabledatafields","TABLEDATAFIELDS","tabledatas","TABLEDATAS","tables","TABLES","tan","TAN","tanh","TANH","time","TIME","tobigdecimal","TOBIGDECIMAL","tobinary","TOBINARY","todate","TODATE","today","TODAY","todouble","TODOUBLE","tohex","TOHEX","toimage","TOIMAGE","tointeger","TOINTEGER","tooctal","TOOCTAL","totext","TOTEXT","treelayer","TREELAYER","trim","TRIM","trunc","TRUNC","uniquearray","UNIQUEARRAY","upper","UPPER","uuid","UUID","value","VALUE","webimage","WEBIMAGE","week","WEEK","weekdate","WEEKDATE","weekday","WEEKDAY","weightedaverage","WEIGHTEDAVERAGE","year","YEAR","yeardelta","YEARDELTA"]; +FormulaJSONs = [{"def":"ABS(number): 返回指定数字的绝对值。绝对值是指没有正负符号的数值。\nNumber:需要求出绝对值的任意实数。\n示例:\nABS(-1.5)等于1.5。\nABS(0)等于0。\nABS(2.5)等于2.5。","name":"ABS","type":"MATH"},{"def":"ACOS(number): 返回指定数值的反余弦值。反余弦值为一个角度,返回角度以弧度形式表示。\nNumber:需要返回角度的余弦值。\n备注:\n 函数的参数必须在-1和1之间,包括-1和1。\n 返回的角度值在0和Pi之间。\n 如果要把返回的角度用度数来表示,用180/PI()乘返回值即可。\n示例:\nACOS(1)等于0(弧度)。\nACOS(0.5)等于1.047197551(Pi/3弧度)。\nACOS(0.5)*180/PI()等于60(度)。","name":"ACOS","type":"MATH"},{"def":"ACOSH(number): 返回给定数值的反双曲余弦。\nNumber:返回值的双曲余弦。\n备注:\n 参数number的值必须大于或等于1。\n ACOSH(COSH(number))=number。\n示例:\nACOSH(1)等于0。\nACOSH(8)等于2.768659383。\nACOSH(5.5)等于2.389526435。","name":"ACOSH","type":"MATH"},{"def":"ADDARRAY(array, insertArray, start):在数组第start个位置插入insertArray中的所有元素,再返回该数组。\n示例:\nADDARRAY([3, 4, 1, 5, 7], [23, 43, 22], 3)返回[3, 4, 23, 43, 22, 1, 5, 7].\nADDARRAY([3, 4, 1, 5, 7], \"测试\", 3)返回[3, 4, \"测试\", 1, 5, 7].\n注意:如果start为小于1的数或者不写start参数,则默认从数组的第一位开始插入数组元素。","name":"ADD2ARRAY","type":"ARRAY"},{"def":"AND(logical1,logical2,…): 当所有参数的值为真时,返回TRUE;当任意参数的值为假时,返回FALSE。\nLogical1,logical2,…:指1到30个需要检验TRUE或FALSE的条件值。\n备注:\n 参数必须是逻辑值,或是含有逻辑值的数组或引用。\n 如果数组或引用中含有文本或空的单元格,则忽略其值。\n 如果在指定的单元格区域中没有逻辑值,AND函数将返回错误信息*NAME?。\n示例:\nAND(1+7=8,5+7=12)等于TRUE。\nAND(1+7=8,5+7=11)等于FALSE。\n如果单元格A1到A4的值分别为TRUE、TRUE、FALSE和TRUE,则:\nAND(A1:A4)等于FALSE。\n如果单元格A5的值在0~50之间,则: AND(0 0,b > 0 or a > 0, b < 0时,公式直接成立;\na < 0,b > 0, ATAN2(a,b)=PI()-ABS(ATAN(b/a))\na < 0,b < 0, ATAN2(a,b)=ABS(ATAN(b/a))-PI()\n 当x_num与y_num都为0时,ATAN2返回错误信息*DIV/0!。\n 用角度制显示返回数值时,把返回数值乘以180/PI()。\n 返回值以弧度表示(返回值大于-pi且小于等于pi)。\n示例:\nATAN2(-2,2)等于2.356194490192345(弧度制的3*pi/4)。\nATAN2(2,2)等于0.785398163(弧度制的pi/4)。\nATAN2(-2,2)*180/PI()等于135(角度制)。","name":"ATAN2","type":"MATH"},{"def":"ATANH(number): 返回数字的反双曲正切值,该函数的参数值即为反双曲正切值的双曲正切值。\nNumber:指介于-1~1之间的任意实数。\n备注:\n 指定的number必须介于-1~1之间(不包括-1,1)。\n ATANH(TANH(number))=number,例如,ATANH(TANH(8))=8。\n示例:\nATANH(-0.5)等于-0.549306144。\nATANH(0)等于0。\nATANH(0.7)等于0.867300528。","name":"ATANH","type":"MATH"},{"def":"AVERAGE(number1,number2,…,countstring): 返回指定数据的平均值。\nNumber1,number2…:用于计算平均值的参数; countString:文字、逻辑值是否参与计数。\n备注:\n 参数必须是数字,或是含有数字的名称,数组或引用。\n 如果数组或引用参数中含有文字,逻辑值,默认参与计数,countString为false则不参与计数;\n 空单元格始终不参与计数,但是,单元格中的零值参与。\n示例:\n如果A1:A6被命名为“ages”,分别等于10,23,文字,29,33及25,则:\nAVERAGE(A1:A6)等于20。\nAVERAGE(A1:A6, false)等于24。\nAVERAGE(ages)等于20。\n如果还有一个年龄为27的,求所有年龄的平均值为: AVERAGE(A1:A6,27)等于21。","name":"AVERAGE","type":"MATH"},{"def":"BITNOT(int):将一个十进制整数进行二进制取反运算。\nint:需要进行转换的十进制数。\n示例:\nBITNOT(3)等于-4。\nBITNOT(12)等于-13。","name":"BITNOT","type":"LOGIC"},{"def":"BITOPERATIOIN(int,int,op) 位运算,返回两个整数根据op进行位运算后的结果。\nint:十进制整数。\nop:位运算操作符,支持\"&\"(与),\"|\"(或),\"^\"(异或),\"<<\"(左移),\">>\"(右移)。\n示例:\nBITOPERATION(4,2,\"&\")表示4与2进行\"与\"运算,结果等于0。\nBITOPERATION(4,2,\"|\")表示4与2进行\"或\"运算,结果等于6。\nBITOPERATION(4,2,\"^\")表示4与2进行\"异或\"运算,结果等于6。\nBITOPERATION(4,2,\"<<\")表示4按位左移2位,结果等于16。\nBITOPERATION(4,2,\">>\")表示4按位右移2位,结果等于1。\nBITOPERATION(4,2,\"^~\")表示4与2进行\"同或\"运算,结果为-7。","name":"BITOPERATION","type":"LOGIC"},{"def":"CEILING(number): 将参数number沿绝对值增大的方向,舍入为最接近的整数\nNumber:指待舍入的数值。\nCEILING(-2.5)等于-3。\nCEILING(0.5)等于1。","name":"CEILING","type":"MATH"},{"def":"CHAR(number): 根据指定数字返回对应的字符。CHAR函数可将计算机其他类型的数字代码转换为字符。\nNumber:用于指定字符的数字,介于1~65535之间(包括1和65535)。\n示例:\nCHAR(88)等于“X”。\nCHAR(45)等于“-”。","name":"CHAR","type":"TEXT"},{"def":"循环引用, =CIRCULAR(A1, B1, C1, D1)等同于=IF(&A1 = 1, 0, B1[A1:-1] + C1[A1:-1] – D1[A1:-1]),如需横向, 则传递第五个参数false","name":"CIRCULAR","type":"HA"},{"def":"CLASS(object):返回object对象的所属的类。","name":"CLASS","type":"OTHER"},{"def":"CNMONEY(number,unit)返回人民币大写。\nnumber:需要转换的数值型的数。\nunit:单位,\"s\",\"b\",\"q\",\"w\",\"sw\",\"bw\",\"qw\",\"y\",\"sy\",\"by\",\"qy\",\"wy\"分别代表“拾”,“佰”,“仟”,“万”,“拾万”,“佰万”,“仟万”,“亿”,“拾亿”,“佰亿”,“仟亿”,“万亿”。\n备注:\n 单位可以为空,如果为空,则直接将number转换为人民币大写,否则先将number与单位的进制相乘,然后再将相乘的结果转换为人民币大写。\n示例:\nCNMONEY(1200)等于壹仟贰佰圆整。\nCNMONEY(12.5,\"w\")等于壹拾贰万伍仟圆整。\nCNMONEY(56.3478,\"bw\")等于伍仟陆佰叁拾肆万柒仟捌佰圆整。\nCNMONEY(3.4567,\"y\")等于叁亿肆仟伍佰陆拾柒万圆整。","name":"CNMONEY","type":"TEXT"},{"def":"CODE(text): 计算文本串中第一个字符的数字代码。返回的代码对应于计算机使用的字符集。\nText:需要计算第一个字符代码的文本或单元格引用。\n示例:\nCODE(\"S\")等于83。\nCODE(\"Spreadsheet\")等于83。","name":"CODE","type":"TEXT"},{"def":"COL()返回当前单元格的列号,必须使用于条件属性中\n示例:\n如果当前单元格是A5,在A5中写入\"=col()\"则返回1。\n如果当前单元格是C6,在C6中写入\"=col()\"则返回3。","name":"COL","type":"REPORT"},{"def":"COLCOUNT(tableData):返回tableData中列的个数。\ntableData:tableData的名字,字符串形式的。\n备注:\n 先从私有数据源中查找,然后再从公有数据源中查找,返回的是第一个查找到的tableData中列数。\n示例:\n以我们提供的数据源FRDemo为例\n新建数据集ds1:SELECT * FROM [CUSTOMER]\nCOLCOUNT(\"ds1\")等于6。\n","name":"COLCOUNT","type":"REPORT"},{"def":"COLNAME(tableData,colIndex)返回的是tableData中列序号colIndex的列名。\ntableData:表示TableData的名字,字符串形式。\ncolIndex:表示列序号。\n备注:\n TableData先从私有数据源中查找,再从公有数据源中查找。\n示例:\nCOLNAME(\"Check\",3)等于AcceName。\nCOLNAME(\"country\",4)等于Area。","name":"COLNAME","type":"REPORT"},{"def":"COMBIN(number,number_chosen): 返回若干个指定对象的组合数。该函数与数学表达式为Cnk功能相同。\nNumber或数学表达式中的“n”指对象总数。\nNumber_chosen或数学表达式中的“k”指在对象总数中某一组合的数量。\n备注:\n Number必须是正整数,number_chosen必须是非负整数。\n 如果number和number_chosen小于0或number小于number_chosen,函数返回错误信息*NUM!。\n 对象组合是对象的子集。与排列不同的是,组合不涉及对象内部的先后顺序,而顺序对排列是非常重要的。\n 假设number=n,number_chosen=k,则: COMBIN(n,k)=Cnk=n!/(k!(n-k)!)。\n示例:\nCOMBIN(5,6)等于*NUM!。\nCOMBIN(5,2)等于10。","name":"COMBIN","type":"MATH"},{"def":"CONCATENATE(text1,text2,...): 将数个字符串合并成一个字符串。\nText1,text2,...:需要合并成单个文本的文本项,可以是字符,数字或是单元格引用。\n示例:\nCONCATENATE(\"Average \",\"Price\")等于“Average Price”。\nCONCATENATE(\"1\",\"2\")等于12。","name":"CONCATENATE","type":"TEXT"},{"def":"CORREL(array1,array2): 求两个相同长度数据系列的相关系数(与Excel的同名函数作用相同)。\n如果数组或引用参数包含文本、逻辑值或空白单元格,则这些值将被忽略;但包含零值的单元格将计算在内。\n函数计算结果出现负数表示负相关。相关系数的取值范围是[-1,1]之间的数。相关系数的绝对值越大,表示误差越小。 Array1 和 Array2 的数据点的个数必须相同,例如:\nCORREL([1,2,3],[2,4,6])=1。\n","name":"CORREL","type":"OTHER"},{"def":"COS(number): 返回一个角度的余弦值。\nNumber:以弧度表示的需要求余弦值的角度。\n备注:\n 要把一个角度转换成弧度值,将角度乘于PI()/180。\n COS(n*2*PI()+number)=COS(number)(其中n为整数,number从-pi到pi)。\n示例:\nCOS(0.5)等于0.877582562。\nCOS(30*PI()/180)等于0.866025404。","name":"COS","type":"MATH"},{"def":"COSH(number): 返回一个数值的双曲线余弦值。\nNumber:需要求其双曲线余弦值的一个实数。\n备注:\n 双曲线余弦值计算公式为: ,其中e是自然对数的底,e=2.71828182845904。\n示例:\nCOSH(3)等于10.06766200。\nCOSH(5)等于74.20994852。\nCOSH(6)等于201.7156361。","name":"COSH","type":"MATH"},{"def":"COUNT(value1,value2,…): 计算数组或数据区域中所含项的个数。\nValue1,value2,…:可包含任何类型数据的参数。","name":"COUNT","type":"MATH"},{"def":"跨层累计, =CROSSLAYERTOTAL(A1, B1, C1, D1)等同于=IF(&B1 >1, D1[B1:-1] + C1, D1[A1:-1,B1:!-1] + C1), 如需横向, 则传递第五个参数false","name":"CROSSLAYERTOTAL","type":"HA"},{"def":"DATE(year,month,day): 返回一个表示某一特定日期的系列数。\nYear:代表年,可为一到四位数。\nMonth:代表月份。\n若1 month 12,则函数把参数值作为月。\n若month>12,则函数从年的一月份开始往上累加。例如: DATE(2000,25,2)等于2002年1月2日的系列数。\nDay:代表日。\n若日期小于等于某指定月的天数,则函数将此参数值作为日。\n若日期大于某指定月的天数,则函数从指定月份的第一天开始往上累加。若日期大于两个或多个月的总天数,则函数把减去两个月或多个月的余数加到第三或第四个月上,依此类推。例如:DATE(2000,3,35)等于2000年4月4日的系列数。\n备注:\n 若需要处理公式中日期的一部分,如年或月等,则可用此公式。\n 若年,月和日是函数而不是函数中的常量,则此公式最能体现其作用。\n示例:\nDATE(1978, 9, 19) 等于1978-09-19.\nDATE(1211, 12, 1) 等于1211-12-01. ","name":"DATE","type":"DATETIME"},{"def":"DATEDELTA(date, deltadays):返回一个日期??date后deltadays的日期。\ndeltaDays可以为正值,负值,零。\n示例:\nDATEDELTA(\"2008-08-08\", -10)等于2008-07-29。\nDATEDELTA(\"2008-08-08\", 10)等于2008-08-18。","name":"DATEDELTA","type":"DATETIME"},{"def":"DATEDIF(start_date,end_date,unit):返回两个指定日期间的天数、月数或年数。\nStart_date:代表所指定时间段的初始日期。\nEnd_date:代表所指定时间段的终止日期。\nUnit:函数返回信息的类型。\n若unit=“Y”,则DATEDIF返回指定时间段的年差数。\n若unit=“M”,则DATEDIF返回指定时间段的月差数。\n若unit=“D”,则DATEDIF返回指定时间段的日差数。\n若unit=“MD”,则DATEDIF忽略年和月,返回指定时间段的日差数。\n若unit=“YM”,则DATEDIF忽略年和日,返回指定时间段的月差数。\n若unit=“YD”,则DATEDIF忽略年,返回指定时间段的日差数。\n示例:\nDATEDIF(\"2001/2/28\",\"2004/3/20\",\"Y\")等于3,即在2001年2月28日与2004年3月20日之间有3个整年。\nDATEDIF(\"2001/2/28\",\"2004/3/20\",\"M\")等于37,即在2001年2月28日与2004年3月20日之间有36个整月。\nDATEDIF(\"2001/2/28\",\"2004/3/20\",\"D\")等于1116,即在2001年2月28日与2004年3月20日之间有1116个整天。\nDATEDIF(\"2001/2/28\",\"2004/3/20\",\"MD\")等于8,即忽略月和年后,2001年2月28日与2004年3月20日的差为8天。\nDATEDIF(\"2001/1/28\",\"2004/3/20\",\"YM\")等于2,即忽略日和年后,2001年1月28日与2004年3月20日的差为2个月。\nDATEDIF(\"2001/2/28\",\"2004/3/20\",\"YD\")等于21,即忽略年后,2001年2月28日与2004年3月20日的差为21天。","name":"DATEDIF","type":"DATETIME"},{"def":"DATEINMONTH(date, number):函数返回在某一个月当中第几天的日期。\n示例:\nDATEINMONTH(\"2008-08-08\", 20) 等于2008-08-20。\nDATEINMONTH(\"2008-08-08\", -1) 等于2008-08-31。","name":"DATEINMONTH","type":"DATETIME"},{"def":"DATEINQUARTER(date, number): 函数返回在某一个季度当中第几天的日期。\n示例:\nDATEINQUARTER(\"2009-05-05\", 20)等于 2009-04-20。","name":"DATEINQUARTER","type":"DATETIME"},{"def":"DATEINWEEK(date, number):函数返回在某一个星期当中第几天的日期。\n示例:\ndateInWeek(\"2008-08-28\", 2)等于2008-08-26。\ndateInWeek(\"2008-08-28\", -1)等于2008-08-31。\n如果最后一个参数为-1,返回该日期所在星期的最后一天\n","name":"DATEINWEEK","type":"DATETIME"},{"def":"DATEINYEAR(date, number):函数返回在一年当中第几天的日期。\n示例:\nDATEINYEAR(2008,100)等于2008-04-09,等价于DATEINYEAR(\"2008-08-08\",100),也返回2008-04-09.\nDATEINYEAR(2008,-1)等于2008-12-31,等价于DATEINYEAR(\"2008-08-08\",-1),也返回2008-12-31.","name":"DATEINYEAR","type":"DATETIME"},{"def":"DATESUBDATE(date1, date2, op):返回两个日期之间的时间差。\nop表示返回的时间单位:\n\"s\",以秒为单位。\n\"m\",以分钟为单位。\n\"h\",以小时为单位。\n\"d\",以天为单位。\n\"w\",以周为单位。\n示例:\nDATESUBDATE(\"2008-08-08\", \"2008-06-06\",\"h\")等于1512。","name":"DATESUBDATE","type":"DATETIME"},{"def":"DATETIME():获取当前日期和时间。\n示例:\n如果系统时间是2005年9月10日 15点18分38秒\n则DATETIME()等于2005-9-10 15:18:36。","name":"DATETIME","type":"DELETE"},{"def":"DATETONUMBER(date):返回自 1970 年 1 月 1 日 00:00:00 GMT 经过的毫秒数。\n示例:\nDATETONUMBER(\"2008-08-08\")等于1218124800000。","name":"DATETONUMBER","type":"DATETIME"},{"def":"DAY:(serial_number)返回日期中的日。DAY是介于1和31之间的一个数。\nSerial_number:含有所求的年的日期.\n备注:\nFineReport将日期保存为系列数,一个系列数代表一个与之匹配的日期,以方便用户对日期进行数值式计算。\n在1900年日期系统中,FineReport电子表格将1900年1月1日保存为系列数2,将1900年1月2日保存为系列数3,\n将1900年1月3日保存为系列数4……依此类推。如在1900年日期系统,1998年1月1日存为系列数35796。\n示例:\nDAY(\"2000/1/1\")等于1。\nDAY(\"2006/05/05\")等于5。\nDAY(\"1997/04/20\")等于20。\nDAY(\"2000-1-1\", \"yyyy-MM-dd\")等于1。\nDAY(\"2006-05-05\", \"yyyy-MM-dd\")等于5。\nDAY(\"1997-04-20\", \"yyyy-MM-dd\")等于20。\nDAY(35796)等于1。","name":"DAY","type":"DATETIME"},{"def":"DAYS360(start_date,end_date,method):按照一年 360 天的算法(每个月以 30 天计,一年共计 12 个月),\n返回两日期间相差的天数,这在会计计算中将会用到。如果财务系统是基于一年 12 个月,每月 30 天,\n可用此函数帮助计算支付款项。\nStart_date 和 end_date :是用于计算期间天数的起止日期。\nMethod : 它指定了在计算中是采用欧洲方法还是美国方法。\nMethod 定义 :\nFALSE或忽略 美国方法 (NASD)。如果起始日期是一个月的 31 号,则等于同月的 30 号。如果终止日期是一个月的\n31号,并且起始日期早于 30 号,则终止日期等于下一个月的 1 号,否则,终止日期等于本月的 30 号。\nTRUE 欧洲方法。无论是起始日期还是终止日期为一个月的 31 号,都将等于本月的 30 号。\n备注:\nFineReport将日期保存为系列数,一个系列数代表一个与之匹配的日期,以方便用户对日期进行数值式计算。\n在1900年日期系统中,FineReport电子表格将1900年1月1日保存为系列数2,将1900年1月2日保存为系列数3,\n将1900年1月3日保存为系列数4……依此类推。如在1900年日期系统,1998年1月1日存为系列数35796。\n示例:\nDAYS360(\"1998/1/30\", \"1998/2/1\") 等于 1","name":"DAYS360","type":"DATETIME"},{"def":"DAYSOFMONTH(date):返回从1900年1月后某年某月包含的天数。\n示例:\nDAYSOFMONTH(\"1900-02-01\")等于28。\nDAYSOFMONTH(\"2008/04/04\")等于30。","name":"DAYSOFMONTH","type":"DATETIME"},{"def":"DAYSOFQUARTER(date): 返回从1900年1月后某年某季度的天数。\n示例:\nDAYSOFQUARTER(\"2009-02-01\")等于90。\nDAYSOFQUARTER(\"2009/05/05\")等于91。","name":"DAYSOFQUARTER","type":"DATETIME"},{"def":"DAYSOFYEAR(year):返回某年包含的天数。\n示例:\nDAYSOFYEAR(2008)等于365,等价于DAYSOFYEAR(\"2008-01-01\")。","name":"DAYSOFYEAR","type":"DATETIME"},{"def":"DAYVALUE(date):返回1900年至 date日期所经历的天数。\n示例:\nDAYVALUE(\"2008/08/08\")等于39668。","name":"DAYVALUE","type":"DATETIME"},{"def":"DECIMAL(number): 返回number的大数类型,常用于精确计算。","name":"DECIMAL","type":"MATH"},{"def":"","name":"DECODE","type":"OTHER"},{"def":"DEGREES(angle): 将弧度转化为度。\nangle:待转换的弧度角。\n示例:\nDEGREES(PI()/2)等于90。\nDEGREES(3.1415926)等于179.9999969。","name":"DEGREES","type":"MATH"},{"def":"","name":"ENCODE","type":"OTHER"},{"def":"ENDWITH(str1,str2):判断字符串str1是否以str2结束。\n备注:\n str1和str2都是大小写敏感的。\n示例:\nENDWITH(\"FineReport\",\"Report\")等于true。\nENDWITH(\"FineReport\",\"Fine\")等于false。\nENDWITH(\"FineReport\",\"report\")等于false。","name":"ENDWITH","type":"TEXT"},{"def":"ENMONEY(value):将给定的BigDemical类型的数字转换成英文金额字符串。\n示例:\nENMONEY(23.49)等于TWENTY THREE AND CENTS FORTY NINE","name":"ENMONEY","type":"TEXT"},{"def":"ENNUMBER(value):将给定的BigDecimal类型的数字转化成英文金额的字符串。","name":"ENNUMBER","type":"TEXT"},{"def":"EVAL(exp)返回表达式exp计算后的结果。\nexp:一个表达式形式字符串。\n备注:\n 只要EVAL中的参数exp最终可以转化成一表达式形式的字符串,比如\"sum(2,4)\",\"2+7\"等等,那么它就可以被计算。\nEVAL(\"2+5\")等于7。\nEVAL(\"count(2,3)\")等于2。\nEVAL(\"sum\"+\"(2,3,5)\")等于10。\nEVAL(IF(true, \"sum\", \"count\") + \"(1,2,3,4)\")等于10。\nEVAL(IF(false, \"sum\", \"count\") + \"(1,2,3,4)\")等于4。","name":"EVAL","type":"OTHER"},{"def":"EVEN(number):返回沿绝对值增大方向取整后最接近的偶数。使用该函数可以处理那些成对出现的对象。\nnumber:所要取整的数值。\n不论正负号如何,数值都朝着远离 0 的方向舍入。如果 number 恰好是偶数,则不须进行任何舍入处理。\n示例:\nEVEN(1.5) 等于 2\nEVEN(3) 等于 4\nEVEN(2) 等于 2\nEVEN(-1) 等于 -2","name":"EVEN","type":"MATH"},{"def":"EXACT(text1,text2): 检测两组文本是否相同。如果完全相同,EXACT函数返回TRUE;否则,返回FALSE。EXACT函数可以区分大小写,但忽略格式的不同。同时也可以利用EXACT函数来检测输入文档的文字。\nText1:需要比较的第一组文本。\nText2:需要比较的第二组文本。\n示例:\nEXACT(\"Spreadsheet\",\"Spreadsheet\")等于TRUE。\nEXACT(\"Spreadsheet\",\"S preadsheet\")等于FALSE。\nEXACT(\"Spreadsheet\",\"spreadsheet\")等于FALSE。","name":"EXACT","type":"TEXT"},{"def":"EXP(number): 返回e的n次幂。常数e为自然对数的底数,等于2.71828182845904。\nNumber:为任意实数,作为常数e的指数。\n备注:\n 如果要返回其他常数作为底数的幂,可以使用指数运算符(^)。例如: 在4^2中,4是底数,而2是指数。\n EXP函数与LN函数互为反函数。\n示例:\nEXP(0)等于1。\nEXP(3)等于20.08553692。\nEXP(LN(2))等于2。","name":"EXP","type":"MATH"},{"def":"FACT(number):返回数的阶乘,一个数的阶乘等于 1*2*3*...*该数。\nnumber:要计算其阶乘的非负数。如果输入的 number 不是整数,则截尾取整。\n示例:\nFACT(1) 等于 1\nFACT(1.9) 等于 FACT(1) 等于 1\nFACT(0) 等于 1\nFACT(5) 等于 1*2*3*4*5 等于 120\n","name":"FACT","type":"MATH"},{"def":"FIELDS(connectionName,tableName):返回tableName这个表中的所有字段名。\n示例:\n数据库BASE中有个名叫task的表的内容如下:\nname start end\na 2008 2009\nb 2009 2012\n那么FIELDS(\"BASE\",\"task\")等于[name,start,end].","name":"FIELDS","type":"REPORT"},{"def":"filename(file)获取文件的文件名。\n当file为单文件时,返回文件名字符串,当file为多文件时,返回文件名的字符串数组。\n如果file不为文件类型,则返回错误信息。\n示例:\n假设文件控件在B2单元格,而B2单元格依次上传了三个不同类型文件{A.doc, C.xls ,B.cpt },则filename(B2)返回值为[“A.doc”, “C.xls”, “B.cpt”]。","name":"FILENAME","type":"OTHER"},{"def":"filesize(file)获取文件的大小,单位为Kb。\n当file为单文件时,返回文件大小,当file为多文件时,返回文件大小的数组。\n如果file不为文件类型,则返回错误信息。\n示例:\n假设文件控件在B2单元格,而B2单元格依次上传了两个大小分别为100字节和10240字节的文件,则filename(B2)返回值为[0.098, 10.0]。","name":"FILESIZE","type":"OTHER"},{"def":"filetype(file)获取文件的类型。\n当file为单文件时,返回文件类型字符串,当file为多文件时,返回文件类型的字符串数组。\n如果file不为文件类型,则返回错误信息。\n示例:\n假设文件控件在B2单元格,而B2单元格依次上传了三个不同类型文件{A.doc, C.xls ,B.txt },则filetype(B2)返回值为[“doc”, “xls”, “txt”]。","name":"FILETYPE","type":"OTHER"},{"def":"FIND(find_text,within_text,start_num):从指定的索引(start_num)处开始,返回第一次出现的指定子字符串(find_text)在此字符串(within_text)中的索引。\nFind_text:需要查找的文本或包含文本的单元格引用。\nWithin_text:包含需要查找文本的文本或单元格引用。\nStart_num:指定进行查找字符的索引位置。within_text里的索引从1开始。如果省略start_num,则假设值为1。\n备注:\n 如果find_text不在within_text中,FIND函数返回值为0。\n 如果start_num不大于0,FIND函数返回错误信息*VALUE!。\n 如果start_num大于within_text的长度,FIND函数返回值为0。\n 如果find_text是空白文本,FIND函数将在搜索串中匹配第一个字符(即编号为start_num或1的字符)。\n示例:\nFIND(\"I\",\"Information\")等于1。\nFIND(\"i\",\"Information\")等于9。\nFIND(\"o\",\"Information\",2)等于4。\nFIND(\"o\",\"Information\",12)等于0。\nFIND(\"o\",\"Information\",-1)等于*VALUE!。","name":"FIND","type":"TEXT"},{"def":"FLOOR(number): 将参数number沿绝对值减小的方向去尾舍入。\nNumber:待舍入的数值。\n示例:\nFLOOR(-2.5)等于-2。\nFLOOR(2.5)等于2。\n","name":"FLOOR","type":"MATH"},{"def":"FORMAT(object,format) : 返回object的format格式。\nobject 需要被格式化对象,可以是String,数字,Object(常用的有Date, Time)。\nformat 格式化的样式。\n示例\nFORMAT(1234.5, \"#,##0.00\") => 1234.50\nFORMAT(1234.5, \"#,##0\") => 1234\nFORMAT(1234.5, \"¥#,##0.00\") => ¥1234.50\nFORMAT(1.5, \"0%\") => 150%\nFORMAT(1.5, \"0.000%\") => 150.000%\nFORMAT(6789, \"##0.0E0\") => 6.789E3\nFORMAT(6789, \"0.00E00\") => 6.79E03\nFORMAT(date(2007,1,1), \"EEEEE, MMMMM dd, yyyy\") => 星期一,一月 01,2007\nFORMAT(date(2007,1,13), \"MM/dd/yyyy\") => 01/13/2007\nFORMAT(date(2007,1,13), \"M-d-yy\") => 1-13-07\nFORMAT(time(16,23,56), \"h:mm:ss a\") => 4:23:56 下午","name":"FORMAT","type":"TEXT"},{"def":"GETUSERDEPARTMENTS():返回角色部门\n示例:\nGETUSERDEPARTMENTS():返回角色所有部门,若多个部门则数组\nGETUSERDEPARTMENTS(3,2):返回角色该部门的第三层和第二层名字,\n若多个部门则返回数组,若没有第三层则只显示第二层","name":"GETUSERDEPARTMENTS","type":"OTHER"},{"def":"GETUSERJOBTITLES():返回角色职务\n示例:\nGETUSERDEPARTMENTS():返回角色所有职务,若多个部门职务则返回职务数组","name":"GETUSERJOBTITLES","type":"OTHER"},{"def":"GREPARRAY(array,fn):函数(返回true或者false)是条件,过滤此数组,最后形成一个新数组。\n示例:\nGREPARRAY([3,4,2,3,6,8,7], item != 3)等于[4,2,6,8,7].\n","name":"GREPARRAY","type":"ARRAY"},{"def":"层次坐标简写, 等同于=A1[A1:-1], 若需=B1[A1:-1]则HIERARCHY(A1, B1).\n若为横向, 偏移量为-2, 则写成HIERARCHY(A1, B1, -2, false), 等同于=B1[;A1:-1].\n公式中最后一个参数表示横纵向, 默认不传递, 表示纵向扩展, 若横向扩展, 则需要加上最后一个参数FALSE来区分. ","name":"HIERARCHY","type":"HA"},{"def":"HOUR(serial_number):返回某一指定时间的小时数。函数指定HOUR为0(0:00)到23(23:00)之间的一个整数。\nSerial_number:包含所求小时的时间。\n示例:\nHOUR(\"11:32:40\")等于11。\nHOUR(\"11:32:40\", \"HH:mm:ss\")等于11。","name":"HOUR","type":"DATETIME"},{"def":"i18n为本软件内置的国际化公式,可以对一些常用的词语进行国际化.\n示例:i18n('File'), 则会在中文语言环境下显示为: 文件, 而在英文语言环境下显示为: File","name":"I18N","type":"REPORT"},{"def":"IF(boolean,number1/string1,number2/string2):判断函数,boolean为true时返回第二个参数,为false时返回第三个。\nboolean: 用于判断的布尔值,true或者false。\nnumber1/string1: 第一个参数,如果boolean为ture,返回这个值。\nnumber2/string2: 第二个参数,如果boolean为false,返回这个值。\n示例:\nIF(true,2,8)等于2\nIF(false,\"first\",\"second\")等于second\nIF(true,\"first\",7)等于first","name":"IF","type":"LOGIC"},{"def":"INARRAY(co, array):返回co在数组array中的位置,如果co不在array中,则返回0.\n示例:\nString[] arr = {\"a\",\"b\",\"c\",\"d\"}\n那么INARRAY(\"b\", arr)等于2.","name":"INARRAY","type":"ARRAY"},{"def":"INDEX(key,val1,val2,...):返回key在val1,val2,...所组成的序列中的位置,不存在于序列中则返回参数的个数.\n备注:\n key和valn可以是任意类型\n示例:\nINDEX(2,2)等于1。\nINDEX(2,1,2)等于2。\nINDEX(2,4,5,6)等于4。\nINDEX(\"b\",\"b\",\"o\",\"y\")等于1。","name":"INDEX","type":"OTHER"},{"def":"INDEXOF(str1,index):返回字符串str1在index位置上的字符。\n备注:\n index是从0开始计数的。\n示例:\nINDEXOF(\"FineReport\",0)等于'F'。\nINDEXOF(\"FineReport\",2)等于'n'。\nINDEXOF(\"FineReport\",9)等于't'。\n\nINDEXOF(array, index):返回数组在index位置上的元素。\n备注:\n index是从1开始计数的。\n示例:\nString[] array = {\"a\", \"b\", \"c\"}\nINDEXOF(array, 1)等于\"a\".\n","name":"INDEXOF","type":"TEXT"},{"def":"INDEXOFARRAY(array, index):返回数组array的第index个元素。\n示例:\nINDEXOFARRAY([\"第一个\", \"第二个\", \"第三个\"], 2)返回\"第二个\"。","name":"INDEXOFARRAY","type":"ARRAY"},{"def":"INT(number): 返回数字下舍入(数值减小的方向)后最接近的整数值。\nNumber:需要下舍入为整数的实数。\n示例:\nINT(4.8)等于4。\nINT(-4.8)等于-5。\nINT(4.3)等于4。\nINT(-4.3)等于-5。\n公式INT(A1)将返回A1单元格中的一个正实数的整数数部分。","name":"INT","type":"MATH"},{"def":"ISNULL(object):判断对象中所有的值是否全部都是NULL或者为空字符串。","name":"ISNULL","type":"OTHER"},{"def":"JOINARRAY(array,sepa):返回一个由sepa作为分隔符的字符串.\narray:[arg1,arg2...]格式的数组;\nsepa:分隔符。\n示例:\nJOINARRAY([1,2],\";\") = [1;2].\nJOINARRAY([hello,world],\"-\") = [hello-world].","name":"JOINARRAY","type":"ARRAY"},{"def":"","name":"JVM","type":"DELETE"},{"def":"逐层累计, =LAYERTOTAL(B1, C1, D1)等同于=D1[B1:-1] + C1, 如需横向, 则传递第四个参数false.如LAYERTOTAL(B1, C1, D1, false)","name":"LAYERTOTAL","type":"HA"},{"def":"LEFT(text,num_chars): 根据指定的字符数返回文本串中的第一个或前几个字符。\nText:包含需要选取字符的文本串或单元格引用。\nNum_chars:指定返回的字符串长度。\n备注:\n Num_chars的值必须等于或大于0。\n 如果num_chars大于整个文本的长度,LEFT函数将返回所有的文本。\n 如果省略num_chars,则默认值为1。\n示例:\nLEFT(\"Fine software\",8)等于“Fine sof”。\nLEFT(\"Fine software\")等于“F”。\n如果单元格A3中含有“China”,则LEFT(A3,2)等于“Ch”。","name":"LEFT","type":"TEXT"},{"def":"LEN(args): 返回文本串中的字符数或者数组的长度。\n需要注意的是:参数args为文本串时,空格也计为字符。\n参数args为数组时,直接返回数组长度。\n示例:\nLEN(\"Evermore software\")等于17。\nLEN(\" \")等于1。\nLEN(['a','b'])等于2。\n","name":"LEN","type":"TEXT"},{"def":"LET(变量名,变量值,变量名,变量值,..., 表达式):局部变量赋值函数,参数的个数N必须为奇数, 最后一个是表达式,前面是N-1(偶数)为局部变量赋值对。\n变量名: 必须是合法的变量名,以字母开头,可以包括字母,数字和下划线\n表达式: 根据前面的N-1个参数赋值后计算出来的结果,这些变量赋值只在这个表达式内部有效\n示例:\nLET(a, 5,b, 6, a+b)等于11\n","name":"LET","type":"OTHER"},{"def":"LN(number):返回一个数的自然对数。自然对数以常数项 e(2.71828182845904)为底。\nnumber:是用于计算其自然对数的正实数。\n示例:\nLN(86) 等于 4.45437\nLN(2.7182818) 等于 1\nLN(EXP(3)) 等于 3\nEXP(LN(4)) 等于 4\n","name":"LN","type":"MATH"},{"def":"LOG(number,base): 按指定的任意底数,返回数值的对数。\nNumber:需要求对数的正实数。\nBase:对数的底数。如果省略底数,默认值为10。\n示例:\nLOG(16,2)等于4。\nLOG(10)等于1。\nLOG(24,3)等于2.892789261。","name":"LOG","type":"MATH"},{"def":"LOG10(number):返回以 10 为底的对数。\nnumber: 用于常用对数计算的正实数。\n示例:\nLOG10(86) 等于 1.934498451\nLOG10(10) 等于 1\nLOG10(1E5) 等于 5\n","name":"LOG10","type":"MATH"},{"def":"LOWER(text): 将所有的大写字母转化为小写字母。\nText:需要转化为小写字母的文本串。LOWER函数不转化文本串中非字母的字符。\n示例:\nLOWER(\"A.M.10:30\")等于“a.m.10:30”。\nLOWER(\"China\")等于“china”。","name":"LOWER","type":"TEXT"},{"def":"LUNAR(year,day,month): 返回当前日期对应的农历时间。\nyear,month,day:分别对应年月日。\n示例:\n如果需要查询2011年7月21日对应的农历时间,则只需输入LUNAR(2011,7,21)结果将显示为:辛卯年六月廿一\n同样,如输入LUNAR(2001,7,21),则显示:辛巳年六月初一 。本公式支持的时间段为1900-2049年。","name":"LUNAR","type":"DATETIME"},{"def":"MAP(object, string, int, int):四个参数分别是索引值,数据集的名字,索引值所在列序号,返回值所在列序号。\n提醒:后两个参数也可以写列名代替。\n根据数据集的名字,找到对应的数据集,找到其中索引列的值为key所对应的返回值。\n数据集的查找方式是依次从报表数据集找到服务器数据集。\n索引列序号与返回值序列号的初始值为1示例:\nMAP(1001, \"employee\", 1, 2)返回employee数据集,第1列中值为1001那条记录中第2列的值。\nMAP(1001, \"employee\", \"name\", \"address\")返回employee数据集,name列中值为1001那条记录中address列的值。","name":"MAP","type":"REPORT"},{"def":"MAPARRAY(array, fn):把一个数组中的项目转换到另一个数组中。\narray (Array): 要转换的数组 \nfn (Function): 处理数组项目的函数 \n示例:\nMAPARRAY([3,4,2,3,6,8,7], item != 3)等于[false,true,true,false,true,true,true].","name":"MAPARRAY","type":"ARRAY"},{"def":"MAX(number1,number2,…): 返回参数列表中的最大值。\nNumber1,number2,…:1到30个需要找出最大值的参数。\n备注:\n 参数可以是数字、空白单元格、逻辑值或数字的文本表达式。\n 如果数组或引用参数中包含可解析文本值,逻辑值,零值或空白单元格,这些值都将参与计算,而不可解析的文本值忽略不计。\n 如果参数中没有任何数字,MAX将返回0。\n示例:\nMAX(0.1,0,1.2)等于1.2。","name":"MAX","type":"MATH"},{"def":"MEDIAN(array1): 返回数据系列的中值(与Excel的同名函数作用相同)。\n\n示例:\nMEDIAN([1,2,3])=2。\n","name":"MEDIAN","type":"OTHER"},{"def":"MID(text,start_num,num_chars): 返回文本串中从指定位置开始的一定数目的字符,该数目由用户指定。\nText:包含要提取字符的文本串。\nStart_num:文本中需要提取字符的起始位置。文本中第一个字符的start_num为1,依此类推。\nNum_chars:返回字符的长度。\n备注:\n 如果start_num大于文本长度,MID函数返回“”(空文本)。\n 如果start_num小于文本长度,并且start_num加上num_chars大于文本长度,MID函数将从start_num指定的起始字符直至文本末的所有字符。\n 如果start_num小于1,MID函数返回错误信息*VALUE!。\n 如果num_chars是负数,MID函数返回错误信息*VALUE!。\n示例:\nMID(\"Finemore software\",10,8)返回“software”。\nMID(\"Finemore software\",30,5)返回“”(空文本)。\nMID(\"Finemore software\",0,8)返回*VALUE!。\nMID(\"Finemore software\",5,-1)返回*VALUE!。","name":"MID","type":"TEXT"},{"def":"MIN(number1,number2,…): 返回参数列表中的最小值。\nNumber1,number2,…:1到30个需要找出最小值的参数。\n备注:\n 若参数中没有数字,函数MIN将返回0。\n 参数应为数字、空白单元格、逻辑值或是表示数值的文本串。如果参数是错误值时,MIN将返回错误信息。\n 如果数组或引用参数中包含可解析文本值,逻辑值,零值或空白单元格,这些值都将参与计算,而不可解析的文本值忽略不计。\n示例:\n如果B1:B4包含3,6,9,12,则:\nMIN(B1:B4)等于3。\nMIN(B1:B4,0)等于0。","name":"MIN","type":"MATH"},{"def":"MINUTE(serial_number):返回某一指定时间的分钟数,其值是介于0与59之间的一个整数。\nserial_number:包含所求分钟数的时间。\n示例:\nMINUTE(\"15:36:25\")等于36。\nMINUTE(\"15:36:25\", \"HH:mm:ss\")等于36。","name":"MINUTE","type":"DATETIME"},{"def":"MOD(number,divisor):返回两数相除的余数。结果的正负号与除数相同。\nnumber:为被除数。\ndivisor:为除数。\n示例:\nMOD(3, 2) 等于 1\nMOD(-3, 2) 等于 1\nMOD(3, -2) 等于 -1\nMOD(-3, -2) 等于 -1\n","name":"MOD","type":"MATH"},{"def":"环比公式, =MOM(A1, B1)等同于=IF(&A1 > 1, B1 / B1[A1:-1],0), 其中如果需要指定偏移量x, 则传递第三个参数x, 第四个参数表示横纵向.\n如=MOM(A1, B1, -2, false)等同于=IF(&A1 > 1, B1 / B1[;A1:-2], 0)","name":"MOM","type":"HA"},{"def":"MONTH:(serial_number)返回日期中的月。月是介于1和12之间的一个数。\nSerial_number:含有所求的月的日期.\n备注:\nFineReport将日期保存为系列数,一个系列数代表一个与之匹配的日期,以方便用户对日期进行数值式计算。\n在1900年日期系统中,FineReport电子表格将1900年1月1日保存为系列数2,将1900年1月2日保存为系列数3,\n将1900年1月3日保存为系列数4……依此类推。如在1900年日期系统,1998年1月1日存为系列数35796。\n示例:\nMONTH(\"2000/1/1\")等于1。\nMONTH(\"2006/05/05\")等于5。\nMONTH(\"1997/04/20\")等于4。\nMONTH(\"2000-1-1\", \"yyyy-MM-dd\")等于1。\nMONTH(\"2006-05-05\", \"yyyy-MM-dd\")等于5。\nMONTH(\"1997-04-20\", \"yyyy-MM-dd\")等于4。\nMONTH(35796)等于1。","name":"MONTH","type":"DATETIME"},{"def":"MONTHDELTA(date,delta):返回指定日期date后delta个月的日期。\n示例:\nMONTHDELTA(\"2008-08-08\", 4)等于2008-12-08。","name":"MONTHDELTA","type":"DATETIME"},{"def":"NOW():获取当前时间。\n示例:\n如果系统时间是2012年5月12日 15点18分38秒\n则NOW()等于2012-05-12 15:18:36。","name":"NOW","type":"DATETIME"},{"def":"NUMTO(number,bool)或NUMTO(number):返回number的中文表示。其中bool用于选择中文表示的方式,当没有bool时采用默认方式显示。\n示例:NUMTO(2345,true)等于二三四五。\n示例:NUMTO(2345,false)等于二千三百四十五。\n示例:NUMTO(2345)等于二千三百四十五。","name":"NUMTO","type":"TEXT"},{"def":"NVL(value1,value2,value3,...):在所有参数中返回第一个不是null的值value1:可以为任意数,也可以为null。\nvalue2:可以为任意数,也可以为null。\n当字符串长度为0时, 返回也为null\n示例:\nNVL(12,20)等于12。\nNVL(null,12)等于12。\nNVL(null,null)等于null。\nNVL(20,null)等于20。\nNVL(null,null,10)等于10。","name":"NVL","type":"OTHER"},{"def":"ODD(number):返回对指定数值进行舍入后的奇数。\nnumber:是要舍入求奇的数值。\n不论正负号如何,数值都朝着远离 0 的方向舍入。如果 number 恰好是奇数,则不须进行任何舍入处理。\n示例:\nODD(1.5) 等于 3\nODD(3) 等于 3\nODD(2) 等于 3\nODD(-1) 等于 -1","name":"ODD","type":"MATH"},{"def":"OR(logical1,logical2,…): 当所有参数的值为假时,返回FALSE;当任意参数的值为真时,返回TRUE。\nLogical1,logical2,…:指1到30个需要检验TRUE或FALSE的条件值。\n备注:\n 参数必须是逻辑值,或是含有逻辑值的数组或引用。\n 如果数组或引用中含有文本或空的单元格,则忽略其值。\n 如果在指定的单元格区域中没有逻辑值,AND函数将返回错误信息*NAME?。\n示例:\nOR(1+7=9,5+7=11)等于FALSE。\nOR(1+7=8,5+7=11)等于TRUE。","name":"OR","type":"LOGIC"},{"def":"PI(number): 是一个数学常量函数,当number为空时,函数返回精确到15位的数值3.141592653589793;当参数不为空时,number表示PI的倍数。\n示例:\nSIN(PI()/2)等于1。\n计算圆的面积的公式: S=PI()*(r^2),其中S为圆的面积,R为圆的半径。\nPI(3)等于9.42477796076938。","name":"PI","type":"MATH"},{"def":"POWER(number,power): 返回指定数字的乘幂。\nNumber:底数,可以为任意实数。\nPower:指数。参数number按照该指数次幂乘方。\n备注:\n 可以使用符号“^”代替POWER,如: POWER(5,2)等于5^2。\n示例:\nPOWER(6,2)等于36。\nPOWER(14,5)等于537824。\nPOWER(4,2/3)等于2.519842100。\nPOWER(3,-2.3)等于0.079913677。","name":"POWER","type":"MATH"},{"def":"PRODUCT(number1,number2, ...):将所有以参数形式给出的数字相乘,并返回乘积值。\nnumber1, number2, ...:为 1 到 30 个需要相乘的数字参数。\n示例:\nPRODUCT(3,4) 等于 12\nPRODUCT(3,4,5) 等于 60\n\n","name":"PRODUCT","type":"MATH"},{"def":"PROMOTION(value1,value2):返回value2在value1上提升的比例。\n示例:\nPROMOTION(12, 14)等于0.166666666,即提升了16.6666666%.\nPROMOTION(-12, 14)等于2.166666666,即提升了216.6666666%.","name":"PROMOTION","type":"MATH"},{"def":"PROPER(text): 将文本中的第一个字母和所有非字母字符后的第一个字母转化成大写,其他字母变为小写。\nText:需要转化为文本的公式、由双引号引用的文本串或是单元格引用。\n示例:\nPROPER(\"Finemore Integrated Office\")等于“Finemore Integrated Office”。\nPROPER(\"100 percent\")等于“100 Percent”。\nPROPER(\"SpreaDSheEt\")等于“Spreadsheet”。","name":"PROPER","type":"TEXT"},{"def":"占比公式, =PROPORTION(A1)等同于=A1/sum(A1[!0])","name":"PROPORTION","type":"HA"},{"def":"RADIANS(angle): 将角度转换成弧度。\nAngle:需要转换为弧度的角度。\n示例:\nRADIANS(90)等于1.570796327(π/2弧度)。","name":"RADIANS","type":"MATH"},{"def":"RAND(): 返回均匀分布的随机数。每计算一次工作表,函数都会返回一个新的随机数值。\n备注:\n 要生成一个位于a和b之间的随机数,可以使用以下的公式: C=RAND()*(b-a)+a。\n 如果要使一个随机产生的数值不随单元格的重计算而改变,可以在编辑框中输入=RAND()并保持编辑状态,然后按F9,将公式永久性地改为随机数。\n示例:\n假如需要生成一个大于等于0,小于60的随机数,使用公式: =RAND()*60。\n假如需要生成一个大于等于0,小于19的随机数,使用公式: =RAND()*19。\n假如需要生成一个大于等于0,小于50的随机数,使用公式: =RAND()*50。","name":"RAND","type":"MATH"},{"def":"RANDBETWEEN(value1,value2):返回value1和value2之间的一个随机整数。\n示例:\nRANDBETWEEN(12.333, 13.233)只会返回13。\nRANDBETWEEN(11.2, 13.3)有可能返回12或者13。","name":"RANDBETWEEN","type":"MATH"},{"def":"RANGE(from,to,step)函数表示从整数from开始,以step为每一步的大小,直到整数to的一个数字序列。\n例如:\nRANGE(1,5,1)表示从1开始,直到5(包括5),每一步大小为1,那么它返回一个数字序列为[1,2,3,4,5]。\nRANGE(-1,6,2)表示从-1开始,直到6(包括6),每一步大小为2,那么它返回一个数字序列为[-1,1,3,5]。\n备注:RANGE函数有三种参数形式:\n1 RANGE(to),默认的from为1,step为1,例如:\n RANGE(4)返回[1,2,3,4]。\n RANGE(-5)返回[]。\n2 RANGE(from,to),默认的step为1,例如:\n RANGE(-1,3)返回[-1,0,1,2,3]。\n RANGE(0,5)返回[0,1,2,3,4,5]。\n3 RANGE(from,to,step),三个参数的情况参照上面的注释,例如:\n RANGE(6,-1,-2)返回[6,4,2,0]。\n RANGE(4,1,1)返回[]。","name":"RANGE","type":"ARRAY"},{"def":"RANK(number,ref,order): 返回一个数在一个数组中的秩。(如果把这个数组排序,该数的秩即为它在数组中的序号。)\nNumber 所求秩的数。(可以是Boolean型,true=1,false=0)\nRef 可以是数组,引用,或一系列数,非实数的值被忽略处理(接受Boolean型,true=1,false=0)。\nOrder 指定求秩的参数,非零为升序,零为降序\n\n备注\n1. RANK对重复的数返回相同的秩,但重复的数影响后面的数的秩,比如,在一组升序排列的整数中,如果5出现了2次,并且秩为3,那么6的秩为5 (没有数的秩是4).\n\n示例\nA1:A5 = 6, 4.5, 4.5, 2, 4\nRANK(A1,A1:A5,1) 即 6 的秩为 5.\n\nRANK(3,1,2,\"go\",3,4,1) = 3, \"go\"被忽略。","name":"RANK","type":"OTHER"},{"def":"RECORDS(connection, table,field):返回数据库表table中字段名field下的所有元素。\n示例:\n数据库BASE中有个名叫task的表的内容如下:\nname start end\na 2008 2009\nb 2009 2012\n那么RECORDS(\"BASE\",\"task\",\"end\")等于[2009,2012].\n\nRECORDS(connection, table,field,row)返回table中field字段下的第row行的记录,field可以为列名也可以为列号。\n RECORDS(\"BASE\",\"task\",\"end\",2)等于2012.\n RECORDS(\"BASE\",\"task\",2,2)等于2009.","name":"RECORDS","type":"REPORT"},{"def":"REGEXP(str, pattern):字符串str是否与正则表达式pattern相匹配。\n示例:\nREGEXP(\"aaaaac\",\"a*c\")等于true。\nREGEXP(\"abc\",\"a*c\")等于false。\n\nREGEXP(str, pattern, intNumber):字符串str是否与具有给定模式 intNumber的正则表达式pattern相匹配。\n示例:\nCASE_INSENSITIVE = 0 启用不区分大小写的匹配。 默认情况下,不区分大小写的匹配假定仅匹配 US-ASCII 字符集中的字符。可以通过指 定 UNICODE_CASE 标志连同此标志来启用 Unicode 感知的、不区分大小写的匹配。 \nMULTILINE = 1 启用多行模式。\nDOTALL = 2 启用 dotall 模式。在 dotall 模式中,表达式 . 可以匹配任何字符,包括行结束符。默认情况下,此表达式不匹配行 结束符。\nUNICODE_CASE = 3 启用 Unicode 感知的大小写折叠。指定此标志后,由 CASE_INSENSITIVE 标志启用时,不区分大小写的匹配将以 符合 Unicode Standard 的方式完成。\nCANON_EQ = 4 启用规范等价。 指定此标志后,当且仅当其完整规范分解匹配时,两个字符才可视为匹配。\nUNIX_LINES = 5 启用 Unix 行模式。 在此模式中,.、^ 和 $ 的行为中仅识别 '\\n' 行结束符。\nLITERAL = 6 启用模式的字面值解析。 指定此标志后,指定模式的输入字符串就会作为字面值字符序列来对待。输入序列中的 元字符或转义序列不具有任何特殊意义。 标志 CASE_INSENSITIVE 和 UNICODE_CASE 在与此标志一起使用时将 对匹配产生影响。其他标志都变得多余了。\nCOMMENTS = 7 模式中允许空白和注释。 此模式将忽略空白和在结束行之前以 # 开头的嵌入式注释。\n \nREGEXP(\"Aaaaabbbbc\",\"a*b*c\", 3)等于true。\nREGEXP(\"Aaaaabbbbc\",\"a*b*c\", 1)等于false。\n\n","name":"REGEXP","type":"TEXT"},{"def":"REMOVEARRAY(array, start, deleteCount):从数组array中删除从第start个元素开始的deleteCount个数组元素,并返回删除后的数组。\n示例:\nREMOVEARRAY([3, 4, 4, 2, 6, 7, 87], 4, 2)返回[3, 4, 4, 7, 87].\n","name":"REMOVEARRAY","type":"ARRAY"},{"def":"REPEAT(text,number_times): 根据指定的次数重复显示文本。REPEAT函数可用来显示同一字符串,并对单元格进行填充。\nText:需要重复显示的文本或包含文本的单元格引用。\nNumber_times:指定文本重复的次数,且为正数。如果number_times为0,REPEAT函数将返回“”(空文本)。如果number_times不是整数,将被取整。REPEAT函数的最终结果通常不大于32767个字符。\n备注:\n 该函数可被用于在工作表中创建简单的直方图。\n示例:\nREPEAT(\"$\",4)等于“$$$$”。\n如果单元格B10的内容为“你好”,REPEAT(B10,3)等于“你好你好你好”。","name":"REPEAT","type":"TEXT"},{"def":"REPLACE(text, texttoreplace, replacetext):根据指定字符串,用其他文本来代替原始文本中的内容。\ntext:需要被替换部分字符的文本或单元格引用。\ntexttoreplace:指定的字符串或正则表达式。\nreplacetext:需要替换部分旧文本的文本。\n示例:\nREPLACE(\"abcd\", \"a\", \"re\")等于\"rebcd\"。\nREPLACE(\"a**d\", \"**d\", \"rose\")等于\"arose\"。\nREPLACE(old_text,start_num,num_chars,new_text): 根据指定的字符数,用其他文本串来替换某个文本串中的部分内容。\nOld_text:需要被替换部分字符的文本或单元格引用。\nStart_num:需要用new_text来替换old_text中字符的起始位置。\nNum_chars:需要用new_text来替换old_text中字符的个数。\nNew_text:需要替换部分旧文本的文本。\n示例:\nREPLACE(\"0123456789\",5,4,\"*\")等于“0123*89”。\nREPLACE(\"1980\",3,2,\"99\")等于“1999”。","name":"REPLACE","type":"TEXT"},{"def":"REVERSE(value):返回与value相反的逻辑值。\n示例:\nREVERSE(true)等于false。","name":"REVERSE","type":"LOGIC"},{"def":"REVERSEARRAY(array):返回数组array的倒序数组。\n示例:\nREVERSEARRAY([\"第一个\", \"第二个\", \"第三个\"])返回[\"第三个\", \"第二个\", \"第一个\"].","name":"REVERSEARRAY","type":"ARRAY"},{"def":"RIGHT(text,num_chars): 根据指定的字符数从右开始返回文本串中的最后一个或几个字符。\nText:包含需要提取字符的文本串或单元格引用。\nNum_chars:指定RIGHT函数从文本串中提取的字符数。Num_chars不能小于0。如果num_chars大于文本串长度,RIGHT函数将返回整个文本。如果不指定num_chars,则默认值为1。\n示例:\nRIGHT(\"It is interesting\",6)等于“esting”。\nRIGHT(\"Share Holder\")等于“r”。\nRIGHT(\"Huge sale\",4)等于“sale”。","name":"RIGHT","type":"TEXT"},{"def":"ROUND(number,num_digits):返回某个数字按指定位数舍入后的数字。\nnumber:需要进行舍入的数字。\nnum_digits:指定的位数,按此位数进行舍入。\n如果 num_digits 大于 0,则舍入到指定的小数位。\n如果 num_digits 等于 0,则舍入到最接近的整数。\n如果 num_digits 小于 0,则在小数点左侧进行舍入。\n示例:\nROUND(2.15, 1) 等于 2.2\nROUND(2.149, 1) 等于 2.1\nROUND(-1.475, 2) 等于 -1.48\nROUND(21.5, -1) 等于 20\n因浮点数存在精度计算丢失问题, 导致计算结果里可能带上9999, 0000这些, \n因此加入第三个参数来控制是否需要去除9999. true表示需要过滤9999, 0000这些数据.","name":"ROUND","type":"MATH"},{"def":"ROUND5(number,num_digits):这个是四舍五入,奇进偶不进。\nnumber:需要进行舍入的数字。\nnum_digits:指定的位数,按此位数进行舍入。\n如果 num_digits 大于 0,则舍入到指定的小数位。\n如果 num_digits 等于 0,则舍入到最接近的整数。\n如果 num_digits 小于 0,则在小数点左侧进行舍入。\n示例:\nROUND5(2.125, 2) 等于 2.12\nROUND5(2.135, 2) 等于 2.14\n","name":"ROUND5","type":"MATH"},{"def":"ROUNDDOWN(number,num_digits):靠近零值,向下(绝对值减小的方向)舍入数字。\nnumber:为需要向下舍入的任意实数。\nnum_digits:舍入后的数字的位数。\n函数 ROUNDDOWN 和函数 ROUND 功能相似,不同之处在于函数 ROUNDDOWN 总是向下舍入数字。\n示例:\nROUNDDOWN(3.2, 0) 等于 3\nROUNDDOWN(76.9,0) 等于 76\nROUNDDOWN(3.14159, 3) 等于 3.141\nROUNDDOWN(-3.14159, 1) 等于 -3.1\nROUNDDOWN(31415.92654, -2) 等于 31,400\n","name":"ROUNDDOWN","type":"MATH"},{"def":"ROUNDUP(number,num_digits):远离零值,向上(绝对值增大的方向)舍入数字。\nnumber:为需要向上舍入的任意实数。\nnum_digits:舍入后的数字的位数。\n函数 ROUNDUP 和函数 ROUND 功能相似,不同之处在于函数 ROUNDUP 总是向上舍入数字。\n示例:\nROUNDUP(3.2,0) 等于 4\nROUNDUP(76.9,0) 等于 77\nROUNDUP(3.14159, 3) 等于 3.142\nROUNDUP(-3.14159, 1) 等于 -3.2\nROUNDUP(31415.92654, -2) 等于 31,500\n\n","name":"ROUNDUP","type":"MATH"},{"def":"ROW()返回当前单元格的行号,必须使用于条件属性中\n示例:\n如果当前单元格为A5,在A5中写入\"=ROW()\"则返回5。\n如果当前单元格为B8,在B8中写入\"=ROW()\"则返回8。","name":"ROW","type":"REPORT"},{"def":"ROWCOUNT(tableData)返回tableData的行数。\ntableData:TableData的名字,字符串形式的。\n备注:\n 先从私有数据源中查找,然后再从公有数据源中查找,返回的是tableData的行数。\n示例:\n以我们提供的数据源FRDemo为例\n新建数据集ds1:SELECT * FROM [CUSTOMER]\nROWCOUNT(\"ds1\")等于20。","name":"ROWCOUNT","type":"REPORT"},{"def":"SECOND(serial_number):返回某一指定时间的秒数,其值是介于0与59之间的一个整数。\nSerial_number:包含所求秒数的时间。\n示例:\nSECOND(\"15:36:25\")等于25。\nSECOND(\"15:36:25\", \"HH:mm:ss\")等于25。","name":"SECOND","type":"DATETIME"},{"def":"SEQ(): 返回数值,在整个报表执行过程中,返回该函数被第几次执行了。\n示例:\nSEQ()在第一次执行时,结果为1。\nSEQ()在第二次执行时,结果为2。","name":"SEQ","type":"OTHER"},{"def":"SIGN(number):返回数字的符号。当数字为正数时返回 1,为零时返回 0,为负数时返回 -1。\nNumber:为任意实数。\n示例:\nSIGN(10) 等于 1\nSIGN(4-4) 等于 0\nSIGN(-0.00001) 等于 -1\n","name":"SIGN","type":"MATH"},{"def":"SIN(number): 计算给定角度的正弦值。\nNumber:待求正弦值的以弧度表示的角度。\n备注:\n 如果参数的单位是度,将其乘以PI()/180即可转换成弧度。\n示例:\nSIN(10)等于-0.5440211108893698。\nSIN(45*PI()/180)等于0.707106781。","name":"SIN","type":"MATH"},{"def":"SINH(number):返回某一数字的双曲正弦值。\nnumber:为任意实数。\n示例:\nSINH(1) 等于 1.175201194\nSINH(-1) 等于 -1.175201194","name":"SINH","type":"MATH"},{"def":"SLICEARRAY(array, start, end):返回数组从第start个到第end个元素(包括第end个元素)。\n示例:\nSLICEARRAY([3, 4, 4, 5, 1, 5, 7], 3, 6)返回[4, 5, 1, 5].\n当不使用end参数时,返回从start开始到数组结束之间的元素。\nSLICEARRAY([3, 4, 4, 5, 1, 5, 7], 3)返回[4, 5, 1, 5, 7].","name":"SLICEARRAY","type":"ARRAY"},{"def":"排名公式, =SORT(A1)等同于=COUNT(A1[!0]{A1 > $A1}) + 1, 默认升序排列, 如需要降序, 则传递参数false,\n =SORT(A1, false)等同于=COUNT(A1[!0]{A1 < $A1}) + 1.","name":"SORT","type":"HA"},{"def":"SORTARRAY(array):返回数组array排过序的数组。\n示例:\nSORTARRAY([3, 4, 4, 5, 1, 5, 7])返回[1, 3, 4, 4, 5, 5, 7].\n注意:数组array的元素类型必须一样,并且要可比较。","name":"SORTARRAY","type":"ARRAY"},{"def":"SPLIT(String1,String2):返回由String2分割String1组成的字符串数组。\nString1:以双引号表示的字符串。\nString2:以双引号表示的分隔符。例如逗号\",\"\n示例:\nSPLIT(\"hello,world,yes\",\",\") = [\"hello\",\"world\",\"yes\"]。\nSPLIT(\"this is very good\",\" \") = [\"this\",\"is\",\"very\",\"good\"]。\n备注:\n如果只有一个参数,则返回一个错误。\n如果有多个参数,则只有前两个起作用。","name":"SPLIT","type":"TEXT"},{"def":"SQL(connectionName,sql,columnIndex,rowIndex)返回通过sql语句从connectionName中获得数据表的第columnIndex列第rowIndex行所对应的元素。\nconnectionName:数据库库的名字,字符串形式;\nsql:SQL语句,字符串形式;\ncolumnIndex:列序号,整形;\nrowIndex:行序号,整形。\n备注:行序号可以不写,这样返回值为数据列。\n示例:\n以我们提供的数据源HSQL为例\nSQL(\"HSQL\",\"SELECT * FROM CUSTOMER\",2,2)等于王先生。","name":"SQL","type":"REPORT"},{"def":"SQRT(number): 返回一个正数的平方根。\nNumber:要求其平方根的任一正数。\n备注:\nNumber必须是一个正数,否则函数返回错误信息*NUM!。\n示例:\nSQRT(64)等于8。\nSQRT(-64)返回*NUM!。","name":"SQRT","type":"MATH"},{"def":"STARTWITH(str1,str2):判断字符串str1是否以str2开始。\n备注:\n str1和str2都是大小写敏感的。\n示例:\nSTARTWITH(\"FineReport\",\"Fine\")等于true。\nSTARTWITH(\"FineReport\",\"Report\")等于false。\nSTARTWITH(\"FineReport\",\"fine\")等于false。","name":"STARTWITH","type":"TEXT"},{"def":"STDEV(array1): 计算数据系列的标准偏差(与Excel的同名函数作用相同)。\n\n示例:\nSTDEV([1,2,3])=1。\n","name":"STDEV","type":"OTHER"},{"def":"SUBSTITUTE(text,old_text,new_text,instance_num): 用new_text替换文本串中的old_text。\nText:需要被替换字符的文本,或含有文本的单元格引用。\nOld_text:需要被替换的部分文本。\nNew_text:用于替换old_text的文本。\nInstance_num:指定用new_text来替换第几次出现的old_text。如果指定了instance_num,则只有指定位置上的old_text被替换,否则文字串中出现的所有old_text都被new_text替换。\n备注:\n 如果需要替换文本串中的指定文本,则使用SUBSTITUTE函数;如果需要替换文本串中指定位置上的任意文本,则使用REPLACE函数。\n示例:\nSUBSTITUTE(\"data base\",\"base\",\"model\")等于“data model”。\nSUBSTITUTE(\"July 28, 2000\",\"2\",\"1\",1)等于“July 18, 2000”。\nSUBSTITUTE(\"July 28, 2000\",\"2\",\"1\")等于“July 18, 1000”。\nSUBSTITUTE(\"July 28, 2000\",\"2\",\"1\",2)等于“July 28, 1000”。 ","name":"SUBSTITUTE","type":"TEXT"},{"def":"SUM(number1,number2,…): 求一个指定单元格区域中所有数字之和。\nNumber1,number2,…:1到30个参数或指定单元格区域中所有数字。\n备注:\n 函数将直接键入参数中的数值、逻辑值及文本表达式计算在内。\n 若参数是数组或引用,则只有数组或单元格引用中的数值进行计算。\n示例:\nSUM(70,80)等于150。\nSUM(\"70\",80,TRUE)等于151,逻辑值“TRUE”作为1来计算;“FALSE”作为0计算;文本“70”作为70来计算。","name":"SUM","type":"MATH"},{"def":"SUMSQ(number1,number2, ...):返回所有参数的平方和。\nnumber1, number2, ...:为 1 到 30 个需要求平方和的参数,也可以使用数组或对数组的引用来代替以逗号分隔的参数。\n示例:\nSUMSQ(3, 4) 等于 25\n","name":"SUMSQ","type":"MATH"},{"def":"switch(表达式, 值1, 结果1, 值2, 结果2, ...)\n如果表达式的结果是值1,整个函数返回结果1\n如果表达式的结果是值2,整个函数返回结果2\n如果表达式的结果是值3,整个函数返回结果3\n等等\n","name":"SWITCH","type":"LOGIC"},{"def":"TABLEDATAFIELDS(tableData):返回tableData中所有的字段名。\n备注:\n 先从报表数据集中查找,然后再从服务器数据集中查找,返回的是tableData的列名组成的数组。\n以我们提供的数据源FRDemo为例\n新建数据集ds1:SELECT * FROM [CUSTOMER]\nTABLEDATAFIELDS(\"ds1\")等于\nCUSTOMERID,CUSTOMERAME,CITY,COUNTRY,TEL,DISTRICT。","name":"TABLEDATAFIELDS","type":"REPORT"},{"def":"TABLEDATAS():返回报表数据集和服务器数据集名字。\n示例:\n服务器数据集有:ds1,ds2,ds3;报表数据集有dsr1,dsr2.\nTABLEDATAS()等于[dsr1,dsr2,ds1,ds2,ds3].\n而TABLEDATAS(0)返回服务器数据集名字;TABLEDATAS(1)返回报表数据集名字;\nTABLEDATAS(0)等于[ds1,ds2,ds3];TABLEDATAS(1)等于[dsr1,dsr2].","name":"TABLEDATAS","type":"REPORT"},{"def":"TABLEAS(connectionName):返回名为connectionName的数据库中的所有表名。\n示例:\n假设在FRDemo这个数据库中,有3个表:a,b,c;\n那么TABLES(\"FRDemo\")等于[a,b,c].","name":"TABLES","type":"REPORT"},{"def":"TAN(number): 返回指定角度的正切值。\nNumber:待求正切值的角度,以弧度表示。如果参数是以度为单位的,乘以Pi()/180后转换为弧度。\n示例:\nTAN(0.8)等于1.029638557。\nTAN(45*Pi()/180)等于1。","name":"TAN","type":"MATH"},{"def":"TANH(number):返回某一数字的双曲正切值。\nnumber:为任意实数。\n双曲正切的计算公式如下:\n示例:\nTANH(-2) 等于 -0.96403\nTANH(0) 等于 0\nTANH(0.5) 等于 0.462117\n","name":"TANH","type":"MATH"},{"def":"TIME(hour,minute,second): 返回代表指定时间的小数。介于0:00:00(12:00:00 A.M.)与23:59:59(11:59:59 P.M.)之间的时间可返回0到0.99999999之间的对应数值。\nHour:介于0到23之间的数。\nMinute:介于0到59之间的数。\nSecond:介于0到59之间的数。\n示例:\nTIME(14,40,0)等于2:40 PM。\nTIME(19,43,24)等于7:43 PM。","name":"TIME","type":"DATETIME"},{"def":"","name":"TOBIGDECIMAL","type":"DELETE"},{"def":"TOBINARY(int): 将一个十进制整型数转换成二进制表示的字符串。\nint:表示需要进行转换的十进制整数。\n示例:\nTOBINARY(10)等于 \"1010\"。\nTOBINARY(20)等于 \"10100\"。","name":"TOBINARY","type":"MATH"},{"def":"TODATE()函数可以将各种日期形式的参数转换为日期类型。\n它有三种参数的形式:\n1 参数是一个日期型的参数,那么直接将这个参数返回。\n示例:\nTODATE(DATE(2007,12,12))返回2007年12月12日组成的日期。\n2 参数是以从1970年1月1日0时0分0秒开始的毫秒数,返回对应的时间。\n示例:\nTODATE(1023542354746)返回2002年6月8日。\n3 参数是日期格式的文本,那么返回这个文本对应的日期。\n示例:\nTODATE(\"2007/10/15\")返回2007年10月5日组成的日期。\nTODATE(\"2007-6-8\")返回2007年6月8日组成的日期。\n4 有两个参数,第一个参数是一个日期格式的文本,第二个参数是用来解析日期的格式。\n示例:\nTODATE(\"1/15/07\",\"mm/dd/yy\")返回07年1月15日组成的日期。\n特别的,\"yyyyMMdd\"是用来解析形如“20081230”之类的日期格式的。比如TODATE(\"20110830\",\"yyyyMMdd\")返回11年08月30日组成的日期\n5 有三个参数,第一个参数是一个日期格式的文本,第二个参数是用来解析日期的格式,第三个参数为解析日期的语言,如:zh(中文),en(英文)。\n示例:\nTODATE(\"星期三 1/15/07\",\"EEE mm/dd/yy\", \"zh\")返回07年1月15日组成的日期,使用“zh(中文)”才能够正常解析“星期三”这个字符串。","name":"TODATE","type":"DATETIME"},{"def":"TODAY():获取当前日期。\n示例:\n如果系统日期是2005年9月10日\n则TODAY()等于2005-9-10。","name":"TODAY","type":"DATETIME"},{"def":"TODOUBLE(text): 将文本转换成Double对象。\nText:需要转换的文本。\n示例:\nTODOUBLE(\"123.21\")等于 new Double(123.21)。","name":"TODOUBLE","type":"TEXT"},{"def":"TOHEX(int): 将一个十进制整型数转换成十六进制表示的字符串。\nint:表示需要进行转换的十进制整数。\n示例:\nTOHEX(15)等于 \"f\"。\nTOHEX(20)等于 \"14\"。","name":"TOHEX","type":"MATH"},{"def":"TOIMAGE(path):显示指定路径下的图片。此处默认开启了图片缓存功能以加速报表的生成.\n如不需要缓存,请在参数后面追加值FALSE,例如:TOIMAGE(\"D:/fr.png\",false).\n如需要指定图片大小,拉伸显示, 则需要添加参数,TOIMAGE(patch, true, width, height).\n示例:=toimage(\"d:/1.jpg\", true, \"50%\", 300), 第三个参数为指定宽度, 第四个参数为指定高度.\n如果参数为整数, 则直接写数字, 如果为百分比, 则需要加上引号, 如\"300%\"","name":"TOIMAGE","type":"OTHER"},{"def":"TOINTEGER(text): 将文本转换成Integer对象。\nText:需要转换的文本。\n示例:\nTOINTEGER(\"123\")等于 new Integer(123)。","name":"TOINTEGER","type":"TEXT"},{"def":"TOOCTAL(int): 将一个十进制整型数转换成八进制表示的字符串。\nint:表示需要进行转换的十进制整数。\n示例:\nTOOCTAL(10)等于 \"12\"。\nTOOCTAL(20)等于 \"24\"。","name":"TOOCTAL","type":"MATH"},{"def":"读取配置文件","name":"TOTEXT","type":"DELETE"},{"def":"treelayer(TreeObject, Int, Boolean, String):\n返回tree对象第n层的值,并且可以设置返回值类型及分隔符。\nTreeObject:tree对象,如$tree。\nInt:想要获得层级的数值,最上层为1,第二层为2,依此类推,若无则返回最底层\n。Boolean:返回值类型为字符串还是数组,默认false,返回数组;为true时返回字符串。\nString:当Boolean为true返回字符串时的分隔符,以双引号表示,默认为逗号\",\",如\";\"。\n示例:\n假设$tree勾选的值为中国-江苏-南京,中国-浙江-杭州,则treelayer($tree, true, ”\\’,\\’”):返回”’,’”分割的所选中节点字符串”南京’,’杭州”treelayer($tree, 2):以数组形式返回第二层[“江苏”,”浙江”]。treelayer($tree, 2, true, ”\\’,\\’”):返回”’,’”分割的字符串江苏’,’浙江。","name":"TREELAYER","type":"OTHER"},{"def":"TRIM(text): 清除文本中所有空格,单词间的单个空格除外,也可用于带有不规则空格的文本。\nText:需要清除空格的文本。\n示例:\nTRIM(\" Monthly Report\")等于Monthly Report。","name":"TRIM","type":"TEXT"},{"def":"TRUNC(number,num_digits):将数字的小数部分截去,返回整数。\nnumber:需要截尾取整的数字。\nnum_digits:用于指定取整精度的数字。\n示例:\nTRUNC(8.9) 等于 8\nTRUNC(-8.9) 等于 -8\nTRUNC(PI()) 等于 3\n","name":"TRUNC","type":"MATH"},{"def":"UNIQUEARRAY(array):去掉数组array中的重复元素。\n示例:\nUNIQUEARRAY([14, 2, 3, 4, 3, 2, 5, 6, 2, 7, 9, 12, 3])返回[14, 2, 3, 4, 5, 6, 7, 9, 12].","name":"UNIQUEARRAY","type":"ARRAY"},{"def":"UPPER(text): 将文本中所有的字符转化为大写。\nText:需要转化为大写字符的文本,或是包含文本的单元格引用。\n示例:\nUPPER(\"notes\")等于“NOTES”。\n如果单元格E5的值为“Examples”,则UPPER(E5)等于“EXAMPLES”。","name":"UPPER","type":"TEXT"},{"def":"UUID():返回随机的UUID。\n示例:UUID()返回36位随机机器数。\n UUID(32)返回32位随机机器数。","name":"UUID","type":"OTHER"},{"def":"VALUE(tableData,col,row)返回tableData中列号为col的值, 行号为row。\ntableData:tableData的名字,字符串形式的。\nrow:行号。\ncol:列号。\n备注:\n 先从报表数据集中查找,然后再从服务器数据集中查找,返回的是tableData的行数。\n示例:\nVALUE(\"country\",5,3)等于South America。\nVALUE(\"Simple\",8,3)等于jonnason。\n示例:VALUE(\"country\",5,\"大陆\")等于South America。\n\nVALUE(tableData,col)返回tableData中列号为col的一列值。\nVALUE(tableData,targetCol, orgCol, element)返回tableData中第targetCol列中的元素,这些元素对应的第orgCol列的值为element。\n示例:\ntableData : co\n国家 省份\n\n中国 江苏\n中国 浙江\n中国 北京\n美国 纽约\n美国 新泽西\nVALUE(\"co\",2, 1, \"中国\")等于[\"江苏\", \"浙江\", \"北京\"]。\n特别说明:列号也可以写为列名。\nVALUE(tableData,targetCol, orgCol, element, idx)返回VALUE(tableData,targetCol, orgCol, element)数组的第idx个值。\n特别说明:idx的值小于0时,会取数组的第一个值,idx的值大于数组长度时,会取数组的最后一个值。\n","name":"VALUE","type":"REPORT"},{"def":"WEBIMAGE(path):在web页面上显示指定路径下的图片。","name":"WEBIMAGE","type":"OTHER"},{"def":"WEEK(serial_num):返回一个代表一年中的第几周的数字。\nSerial_num:表示输入的日期。\n备注:\nFineReport将日期保存为系列数,一个系列数代表一个与之匹配的日期,以方便用户对日期进行数值式计算。\n在1900年日期系统中,FineReport电子表格将1900年1月1日保存为系列数2,将1900年1月2日保存为系列数3,\n将1900年1月3日保存为系列数4……依此类推。如在1900年日期系统,1998年1月1日存为系列数35796。\n示例:\nWEEK(\"2010/1/1\")等于52。\nWEEK(\"2010/1/6\")等于1。\nWEEK(35796)等于1。","name":"WEEK","type":"DATETIME"},{"def":"weekdate(year,month,weekOfMonth,dayOfWeek): 返回指定年月的指定周的周几的具体日期。\n示例:\nweekdate(2009,10,2,1)\n返回的是2009年的10月的第二个周的第一天即星期天的日期,返回的是2009-10-04\n最后一个参数dayOfWeek为-1时,表示这个周的最后一天\n示例:\nweekdate(2009,12,1,-1)\n返回的是2009年的12月的第一个周的最后一天即星期六的日期,返回的是2009-12-05\n","name":"WEEKDATE","type":"DATETIME"},{"def":"WEEKDAY(Serial_number):获取日期并返回星期数。返回值为介于0到6之间的某一整数,分别代表星期中的某一天(从星期日到星期六)。\nSerial_number:输入的日期\n备注:\nFineReport将日期保存为系列数,一个系列数代表一个与之匹配的日期,以方便用户对日期进行数值式计算。\n在1900年日期系统中,FineReport电子表格将1900年1月1日保存为系列数2,将1900年1月2日保存为系列数3,\n将1900年1月3日保存为系列数4……依此类推。如在1900年日期系统,1998年1月1日存为系列数35796。\n举例:\nWEEKDAY(\"2005/9/10\")等于6(星期六)。\nWEEKDAY(\"2005/9/11\")等于0(星期日)。\nWEEKDAY(35796)等于4(星期四)。\n","name":"WEEKDAY","type":"DATETIME"},{"def":"WEIGHTEDAVERAGE(A1:A4,B1:B4): 返回指定数据的加权平均值。\n加权平均数是不同比重数据的平均数,加权平均数就是把原始数据按照合理的比例来计算。\nA1:A4,B1:B4:用于计算平均值的参数,A1~A4为数据,B1~B4为权值。\n示例:\n如果A1:A4为10,9,8,7,B1:B4为0.2,0.1,0.3,0.4则:\nWEIGHTEDAVERAGE(A1:A4,B1:B4)等于8.1。","name":"WEIGHTEDAVERAGE","type":"MATH"},{"def":"YEAR:(serial_number)返回日期中的年。Year是介于1900和9999之间的一个数。\nSerial_number:含有所求的年的日期.\n备注:\nFineReport将日期保存为系列数,一个系列数代表一个与之匹配的日期,以方便用户对日期进行数值式计算。\n在1900年日期系统中,FineReport电子表格将1900年1月1日保存为系列数2,将1900年1月2日保存为系列数3,\n将1900年1月3日保存为系列数4……依此类推。如在1900年日期系统,1998年1月1日存为系列数35796。\n示例:\nYEAR(\"2000/1/1\")等于2000。\nYEAR(\"2006/05/05\")等于2006。\nYEAR(\"1997/04/20\")等于1997。\nYEAR(\"2000-1-1\", \"yyyy-MM-dd\")等于2000。\nYEAR(\"2006-05-05\", \"yyyy-MM-dd\")等于2006。\nYEAR(\"1997-04-20\", \"yyyy-MM-dd\")等于1997。\nYEAR(35796)等于1998。","name":"YEAR","type":"DATETIME"},{"def":"YEARDELTA(date, delta):返回指定日期后delta年的日期。\n示例:\nYEARDELTA(\"2008-10-10\",10)等于2018-10-10。","name":"YEARDELTA","type":"DATETIME"}]; \ No newline at end of file From ddf895029c86119190d4c0c9ff786765c5bf3a6d Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Tue, 21 Mar 2017 18:37:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gruntfile.js | 1 + demo/js/center.js | 7 +- dist/case.js | 3036 ++++++++++++----- src/case/button/item.multiselect.js | 7 +- src/case/button/item.singleselect.js | 5 +- .../button/node/node.multilayer.icon.arrow.js | 6 +- .../treeitem/item.multilayer.icon.treeleaf.js | 3 - src/case/calendar/calendar.js | 24 +- src/case/colorpicker/editor.colorpicker.js | 44 +- src/case/combo/combo.bubble.js | 210 ++ src/case/combo/popup.bubble.bar.js | 44 + src/case/combo/popup.bubble.js | 73 + src/case/editor/editor.record.js | 80 +- src/case/editor/editor.shelter.js | 4 + src/case/editor/editor.sign.js | 16 +- src/case/editor/editor.state.js | 49 +- src/case/editor/editor.state.simple.js | 11 +- src/case/floatbox/floatboxsection.bar.js | 11 +- src/case/layer/layer.multiselect.js | 2 +- src/case/logintimeout/login.timeout.js | 242 ++ .../{pager.all.js => pager.all.count.js} | 80 +- ...s~67b55d486e769f445942f15883303ca839ffd092 | 163 + src/case/pager/pager.direction.js | 103 +- src/case/pager/pager.js | 288 ++ src/case/pager/pager.number.js | 116 - src/case/pager/pager.skip.js | 112 - src/case/table/table.adaptive.js | 235 ++ .../table/table.dynamicsummarylayertree.js | 268 +- src/case/table/table.dynamicsummarytree.js | 221 +- src/case/table/table.layertree.cell.js | 32 - src/case/table/table.layertree.js | 239 +- src/case/table/table.style.cell.js | 46 + src/case/table/table.tree.js | 330 ++ src/case/table/tabler.js | 92 - src/case/tip/tip.tooltip.js | 52 +- src/case/trigger/trigger.text.js | 2 + src/case/trigger/trigger.text.select.js | 2 +- src/case/trigger/trigger.text.select.small.js | 2 +- src/case/zclip/zclip.js | 2 +- 39 files changed, 4493 insertions(+), 1767 deletions(-) create mode 100644 src/case/combo/combo.bubble.js create mode 100644 src/case/combo/popup.bubble.bar.js create mode 100644 src/case/combo/popup.bubble.js create mode 100644 src/case/logintimeout/login.timeout.js rename src/case/pager/{pager.all.js => pager.all.count.js} (57%) create mode 100644 src/case/pager/pager.all.count.js~67b55d486e769f445942f15883303ca839ffd092 create mode 100644 src/case/pager/pager.js delete mode 100644 src/case/pager/pager.number.js delete mode 100644 src/case/pager/pager.skip.js create mode 100644 src/case/table/table.adaptive.js delete mode 100644 src/case/table/table.layertree.cell.js create mode 100644 src/case/table/table.style.cell.js create mode 100644 src/case/table/table.tree.js delete mode 100644 src/case/table/tabler.js diff --git a/Gruntfile.js b/Gruntfile.js index ab485ff64..db9878b7e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -47,6 +47,7 @@ module.exports = function (grunt) { //实现好的一些基础实例 caseJs: { src: [ + 'src/case/combo/popup.bubble.js', 'src/case/**/*.js' ], dest: 'dist/case.js' diff --git a/demo/js/center.js b/demo/js/center.js index 48f0e7a65..c4bb8325b 100644 --- a/demo/js/center.js +++ b/demo/js/center.js @@ -9,13 +9,8 @@ Demo.Center = BI.inherit(BI.Widget, { ref: function () { self.tab = this; }, - defaultShowIndex: 0, + defaultShowIndex: "demo.face", cardCreator: function (v) { - if (v === 0) { - return BI.createWidget({ - type: "demo.face" - }) - } return BI.createWidget({ type: v }); diff --git a/dist/case.js b/dist/case.js index 32e9c7e42..94545560f 100644 --- a/dist/case.js +++ b/dist/case.js @@ -1,4 +1,76 @@ /** + * Created by GUY on 2017/2/8. + * + * @class BI.BubblePopupView + * @extends BI.PopupView + */ +BI.BubblePopupView = BI.inherit(BI.PopupView, { + _defaultConfig: function () { + var config = BI.BubblePopupView.superclass._defaultConfig.apply(this, arguments); + return BI.extend(config, { + baseCls: config.baseCls + " bi-bubble-popup-view" + }) + }, + _init: function () { + BI.BubblePopupView.superclass._init.apply(this, arguments); + }, + + showLine: function (direction) { + var pos = {}, op = {}; + switch (direction) { + case "left": + pos = { + top: 0, + bottom: 0, + left: -1 + }; + op = {width: 3}; + break; + case "right": + pos = { + top: 0, + bottom: 0, + right: -1 + }; + op = {width: 3}; + break; + case "top": + pos = { + left: 0, + right: 0, + top: -1 + }; + op = {height: 3}; + break; + case "bottom": + pos = { + left: 0, + right: 0, + bottom: -1 + }; + op = {height: 3}; + break; + default: + break; + } + this.line = BI.createWidget(op, { + type: "bi.layout", + cls: "bubble-popup-line" + }); + pos.el = this.line; + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [pos] + }) + }, + + hideLine: function () { + this.line && this.line.destroy(); + } +}); + +$.shortcut("bi.bubble_popup_view", BI.BubblePopupView);/** * 可以改变图标的button * * Created by GUY on 2016/2/2. @@ -197,6 +269,11 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, { })))); }, + setEnable: function (v) { + BI.MultiSelectItem.superclass.setEnable.apply(this, arguments); + this.checkbox.setEnable(v); + }, + doRedMark: function(){ this.text.doRedMark.apply(this.text, arguments); }, @@ -215,7 +292,7 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, { this.checkbox.setSelected(v); } }); - +BI.MultiSelectItem.EVENT_CHANGE = "EVENT_CHANGE"; $.shortcut("bi.multi_select_item", BI.MultiSelectItem);/** * Created by GUY on 2016/2/2. * @@ -284,7 +361,8 @@ BI.SingleSelectItem = BI.inherit(BI.BasicButton, { return BI.extend(BI.SingleSelectItem.superclass._defaultConfig.apply(this, arguments), { extraCls: "bi-single-select-item bi-list-item-active", hgap: 10, - height: 25 + height: 25, + textAlign: "left", }) }, _init: function () { @@ -293,7 +371,7 @@ BI.SingleSelectItem = BI.inherit(BI.BasicButton, { this.text = BI.createWidget({ type: "bi.label", element: this, - textAlign: "left", + textAlign: o.textAlign, whiteSpace: "nowrap", textHeight: o.height, height: o.height, @@ -836,9 +914,9 @@ $.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArrow this.node = BI.createWidget({ type: "bi.icon_arrow_node", iconCls: o.iconCls, - logic: { - dynamic: true - }, + //logic: { + // dynamic: true + //}, id: o.id, pId: o.pId, open: o.open, @@ -1479,9 +1557,6 @@ BI.MultiLayerIconTreeLeafItem = BI.inherit(BI.BasicButton, { this.item = BI.createWidget({ type: "bi.icon_tree_leaf_item", iconCls: o.iconCls, - logic: { - dynamic: true - }, id: o.id, pId: o.pId, isFront: true, @@ -1655,12 +1730,13 @@ BI.Calendar = BI.inherit(BI.Widget, { De.setFullYear(Y, M, D); log.ymd = [De.getFullYear(), De.getMonth(), De.getDate()]; - Date._MD[1] = Date.isLeap(log.ymd[0]) ? 29 : 28; + var MD = Date._MD.slice(0); + MD[1] = Date.isLeap(log.ymd[0]) ? 29 : 28; De.setFullYear(log.ymd[0], log.ymd[1], 1); log.FDay = De.getDay(); - log.PDay = Date._MD[M === 0 ? 11 : M - 1] - log.FDay + 1; + log.PDay = MD[M === 0 ? 11 : M - 1] - log.FDay + 1; log.NDay = 1; var items = []; @@ -1671,7 +1747,7 @@ BI.Calendar = BI.inherit(BI.Widget, { DD = i + log.PDay; MM === 1 && (YY -= 1); MM = MM === 1 ? 12 : MM - 1; - } else if (i >= log.FDay && i < log.FDay + Date._MD[log.ymd[1]]) { + } else if (i >= log.FDay && i < log.FDay + MD[log.ymd[1]]) { DD = i - log.FDay + 1; if (i - log.FDay + 1 === log.ymd[2]) { td.currentDay = true; @@ -1792,6 +1868,23 @@ BI.extend(BI.Calendar, { var page = (json.year - year) * 12; page += json.month - month; return page; + }, + getDateJSONByPage: function(v){ + var months = new Date().getMonth(); + var page = v; + + //对当前page做偏移,使到当前年初 + page = page + months; + + var year = BI.parseInt(page / 12); + if(page < 0 && page % 12 !== 0){ + year--; + } + var month = page >= 0 ? (page % 12) : ((12 + page % 12) % 12); + return { + year: new Date().getFullYear() + year, + month: month + } } }); @@ -2467,7 +2560,7 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.ColorPickerEditor.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-color-picker-editor", - width: 190, + width: 200, height: 20 }) }, @@ -2495,6 +2588,7 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, { cls: "color-picker-editor-input", validationChecker: checker, errorText: BI.i18nText("BI-Color_Picker_Error_Text"), + allowBlank: true, value: 255, width: 35, height: 20 @@ -2511,6 +2605,22 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, { this.G = Ws[1]; this.B = Ws[2]; + this.none = BI.createWidget({ + type: "bi.checkbox" + }); + this.none.on(BI.Checkbox.EVENT_CHANGE, function () { + if (this.isSelected()) { + self.lastColor = self.getValue(); + self.setValue(""); + } else { + self.setValue(self.lastColor || "#000000"); + } + if (self.R.isValid() && self.G.isValid() && self.B.isValid()) { + self.colorShow.element.css("background-color", self.getValue()); + self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); + } + }); + BI.createWidget({ type: "bi.htape", element: this, @@ -2523,32 +2633,43 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, { width: 20 }, { el: this.R, - width: 35 + width: 32 }, { el: RGB[1], lgap: 10, width: 20 }, { el: this.G, - width: 35 + width: 32 }, { el: RGB[2], lgap: 10, width: 20 }, { el: this.B, - width: 35 + width: 32 + }, { + el: { + type: "bi.center_adapt", + items: [this.none] + }, + width: 20 }] }) }, setValue: function (color) { - color || (color = "#000000"); + if (!color) { + color = ""; + this.none.setSelected(true); + } else { + this.none.setSelected(false); + } this.colorShow.element.css("background-color", color); var json = BI.DOM.rgb2json(BI.DOM.hex2rgb(color)); - this.R.setValue(json.r); - this.G.setValue(json.g); - this.B.setValue(json.b); + this.R.setValue(BI.isNull(json.r) ? "" : json.r); + this.G.setValue(BI.isNull(json.g) ? "" : json.g); + this.B.setValue(BI.isNull(json.b) ? "" : json.b); }, getValue: function () { @@ -2561,15 +2682,267 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, { }); BI.ColorPickerEditor.EVENT_CHANGE = "ColorPickerEditor.EVENT_CHANGE"; $.shortcut("bi.color_picker_editor", BI.ColorPickerEditor);/** + * Created by GUY on 2017/2/8. + * + * @class BI.BubbleCombo + * @extends BI.Widget + */ +BI.BubbleCombo = BI.inherit(BI.Widget, { + _const: { + TRIANGLE_LENGTH: 6 + }, + _defaultConfig: function () { + return BI.extend(BI.BubbleCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-bubble-combo", + trigger: "click", + toggle: true, + direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right + isDefaultInit: false, + isNeedAdjustHeight: true,//是否需要高度调整 + isNeedAdjustWidth: true, + stopPropagation: false, + adjustLength: 0,//调整的距离 + // adjustXOffset: 0, + // adjustYOffset: 10, + hideChecker: BI.emptyFn, + offsetStyle: "left", //left,right,center + el: {}, + popup: {}, + }) + }, + _init: function () { + BI.BubbleCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + trigger: o.trigger, + toggle: o.toggle, + direction: o.direction, + isDefaultInit: o.isDefaultInit, + isNeedAdjustHeight: o.isNeedAdjustHeight, + isNeedAdjustWidth: o.isNeedAdjustWidth, + adjustLength: this._getAdjustLength(), + stopPropagation: o.stopPropagation, + adjustXOffset: 0, + adjustYOffset: 0, + hideChecker: o.hideChecker, + offsetStyle: o.offsetStyle, + el: o.el, + popup: BI.extend({ + type: "bi.bubble_popup_view" + }, o.popup), + }); + this.combo.on(BI.Combo.EVENT_TRIGGER_CHANGE, function () { + self.fireEvent(BI.BubbleCombo.EVENT_TRIGGER_CHANGE, arguments); + }); + this.combo.on(BI.Combo.EVENT_CHANGE, function () { + self.fireEvent(BI.BubbleCombo.EVENT_CHANGE, arguments); + }); + this.combo.on(BI.Combo.EVENT_EXPAND, function () { + self.fireEvent(BI.BubbleCombo.EVENT_EXPAND, arguments); + }); + this.combo.on(BI.Combo.EVENT_COLLAPSE, function () { + self.fireEvent(BI.BubbleCombo.EVENT_COLLAPSE, arguments); + }); + this.combo.on(BI.Combo.EVENT_AFTER_INIT, function () { + self.fireEvent(BI.BubbleCombo.EVENT_AFTER_INIT, arguments); + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, arguments); + }); + this.combo.on(BI.Combo.EVENT_AFTER_POPUPVIEW, function () { + self._showTriangle(); + self.fireEvent(BI.BubbleCombo.EVENT_AFTER_POPUPVIEW, arguments); + }); + this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { + self._hideTriangle(); + self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW, arguments); + }); + this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { + self.fireEvent(BI.BubbleCombo.EVENT_AFTER_HIDEVIEW, arguments); + }); + }, + + _getAdjustLength: function () { + return this._const.TRIANGLE_LENGTH + this.options.adjustLength; + }, + + _createTriangle: function (direction) { + var pos = {}, op = {}; + var adjustLength = this._getAdjustLength(); + switch (direction) { + case "left": + pos = { + top: 0, + bottom: 0, + left: -adjustLength + }; + op = {width: this._const.TRIANGLE_LENGTH}; + break; + case "right": + pos = { + top: 0, + bottom: 0, + right: -adjustLength + }; + op = {width: this._const.TRIANGLE_LENGTH}; + break; + case "top": + pos = { + left: 0, + right: 0, + top: -adjustLength + }; + op = {height: this._const.TRIANGLE_LENGTH}; + break; + case "bottom": + pos = { + left: 0, + right: 0, + bottom: -adjustLength + }; + op = {height: this._const.TRIANGLE_LENGTH}; + break; + default: + break; + } + this.triangle = BI.createWidget(op, { + type: "bi.center_adapt", + items: [{ + type: "bi.layout", + cls: "bubble-combo-triangle-" + direction + }] + }); + pos.el = this.triangle; + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [pos] + }) + }, + + _createLeftTriangle: function () { + this._createTriangle("left"); + }, + + _createRightTriangle: function () { + this._createTriangle("right"); + }, + + _createTopTriangle: function () { + this._createTriangle("top"); + }, + + _createBottomTriangle: function () { + this._createTriangle("bottom"); + }, + + _showTriangle: function () { + var pos = this.combo.getPopupPosition(); + switch (pos.dir) { + case "left,top": + case "left,bottom": + this._createLeftTriangle(); + this.combo.getView().showLine("right"); + break; + case "right,top": + case "right,bottom": + this._createRightTriangle(); + this.combo.getView().showLine("left"); + break; + case "top,left": + case "top,right": + this._createTopTriangle(); + this.combo.getView().showLine("bottom"); + break; + case "bottom,left": + case "bottom,right": + this._createBottomTriangle(); + this.combo.getView().showLine("top"); + break; + } + }, + + _hideTriangle: function () { + this.triangle && this.triangle.destroy(); + this.combo.getView().hideLine(); + }, + + hideView: function () { + this._hideTriangle(); + this.combo && this.combo.hideView(); + }, + + showView: function () { + this.combo && this.combo.showView(); + } +}); + +BI.BubbleCombo.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE"; +BI.BubbleCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.BubbleCombo.EVENT_EXPAND = "EVENT_EXPAND"; +BI.BubbleCombo.EVENT_COLLAPSE = "EVENT_COLLAPSE"; +BI.BubbleCombo.EVENT_AFTER_INIT = "EVENT_AFTER_INIT"; + + +BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.BubbleCombo.EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW"; +BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW"; +BI.BubbleCombo.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW"; +$.shortcut("bi.bubble_combo", BI.BubbleCombo);/** + * Created by GUY on 2017/2/8. + * + * @class BI.BubblePopupBarView + * @extends BI.BubblePopupView + */ +BI.BubblePopupBarView = BI.inherit(BI.BubblePopupView, { + _defaultConfig: function () { + return BI.extend(BI.BubblePopupBarView.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-bubble-bar-popup-view", + buttons: [{value: BI.i18nText(BI.i18nText("BI-Basic_Sure"))}, {value: BI.i18nText("BI-Basic_Cancel"), level: "ignore"}] + }) + }, + _init: function () { + BI.BubblePopupBarView.superclass._init.apply(this, arguments); + }, + _createToolBar: function () { + var o = this.options, self = this; + + var items = []; + BI.each(o.buttons.reverse(), function (i, buttonOpt) { + if(BI.isWidget(buttonOpt)){ + items.push(buttonOpt); + }else{ + items.push(BI.extend({ + type: 'bi.button', + height: 30, + handler: function (v) { + self.fireEvent(BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, v); + } + }, buttonOpt)) + } + }); + return BI.createWidget({ + type: 'bi.right_vertical_adapt', + height: 40, + hgap: 10, + bgap: 10, + items: items + }); + } +}); +BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON"; +$.shortcut("bi.bubble_bar_popup_view", BI.BubblePopupBarView);/** * guy * 记录内容的输入框 * @class BI.RecordEditor * @extends BI.Single */ BI.RecordEditor = BI.inherit(BI.Single, { - _defaultConfig: function() { + _defaultConfig: function () { var conf = BI.RecordEditor.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf , { + return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-record-editor", hgap: 4, vgap: 2, @@ -2586,7 +2959,7 @@ BI.RecordEditor = BI.inherit(BI.Single, { }) }, - _init : function() { + _init: function () { BI.RecordEditor.superclass._init.apply(this, arguments); this.contents = []; var self = this, o = this.options; @@ -2604,7 +2977,7 @@ BI.RecordEditor = BI.inherit(BI.Single, { validationChecker: o.validationChecker, quitChecker: o.quitChecker, mouseOut: o.mouseOut, - allowBlank : o.allowBlank, + allowBlank: o.allowBlank, watermark: o.watermark, errorText: o.errorText }); @@ -2616,64 +2989,64 @@ BI.RecordEditor = BI.inherit(BI.Single, { this.editor.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }); - this.editor.on(BI.Editor.EVENT_FOCUS, function(){ + this.editor.on(BI.Editor.EVENT_FOCUS, function () { self._checkInputState(); self.fireEvent(BI.RecordEditor.EVENT_FOCUS, arguments); }); - this.editor.on(BI.Editor.EVENT_BLUR, function(){ + this.editor.on(BI.Editor.EVENT_BLUR, function () { self._checkInputState(); self.fireEvent(BI.RecordEditor.EVENT_BLUR, arguments); }); - this.editor.on(BI.Editor.EVENT_CLICK, function(){ + this.editor.on(BI.Editor.EVENT_CLICK, function () { self.fireEvent(BI.RecordEditor.EVENT_CLICK, arguments); }); - this.editor.on(BI.Editor.EVENT_CHANGE, function(){ + this.editor.on(BI.Editor.EVENT_CHANGE, function () { self.fireEvent(BI.RecordEditor.EVENT_CHANGE, arguments); }); - this.editor.on(BI.Editor.EVENT_KEY_DOWN, function(v){ + this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) { self.fireEvent(BI.RecordEditor.EVENT_KEY_DOWN, arguments); }); - this.editor.on(BI.Editor.EVENT_VALID, function(){ + this.editor.on(BI.Editor.EVENT_VALID, function () { self.fireEvent(BI.RecordEditor.EVENT_VALID, arguments); }); - this.editor.on(BI.Editor.EVENT_SPACE, function(){ + this.editor.on(BI.Editor.EVENT_SPACE, function () { self.fireEvent(BI.RecordEditor.EVENT_SPACE, arguments); }); - this.editor.on(BI.Editor.EVENT_CONFIRM, function(){ - self.setValue(self.getValue()); + this.editor.on(BI.Editor.EVENT_CONFIRM, function () { + self.setState(self.getValue()); self.editor.isValid() && self.editor.setValue(""); self.fireEvent(BI.RecordEditor.EVENT_CONFIRM, arguments); }); - this.editor.on(BI.Editor.EVENT_START, function(){ + this.editor.on(BI.Editor.EVENT_START, function () { self.fireEvent(BI.RecordEditor.EVENT_START, arguments); }); - this.editor.on(BI.Editor.EVENT_PAUSE, function(){ + this.editor.on(BI.Editor.EVENT_PAUSE, function () { self.fireEvent(BI.RecordEditor.EVENT_PAUSE, arguments); }); - this.editor.on(BI.Editor.EVENT_STOP, function(){ + this.editor.on(BI.Editor.EVENT_STOP, function () { self.fireEvent(BI.RecordEditor.EVENT_STOP, arguments); }); this.editor.on(BI.Editor.EVENT_ENTER, function () { self.fireEvent(BI.RecordEditor.EVENT_ENTER, arguments); }); - this.editor.on(BI.Editor.EVENT_BACKSPACE, function(){ + this.editor.on(BI.Editor.EVENT_BACKSPACE, function () { self._checkInputState(); }); - this.editor.on(BI.Editor.EVENT_REMOVE, function(){ - if(!BI.isEmpty(self.contents)){ + this.editor.on(BI.Editor.EVENT_REMOVE, function () { + if (!BI.isEmpty(self.contents)) { self.contents.pop().destroy(); self.setValue(self.getValue()); self._adjustInputWidth(); } }); - this.editor.on(BI.Editor.EVENT_ERROR, function(){ + this.editor.on(BI.Editor.EVENT_ERROR, function () { self.fireEvent(BI.RecordEditor.EVENT_ERROR, arguments); }); - this.editor.on(BI.Editor.EVENT_RESTRICT, function(){ + this.editor.on(BI.Editor.EVENT_RESTRICT, function () { self.fireEvent(BI.RecordEditor.EVENT_RESTRICT, arguments); }); - this.editor.on(BI.Editor.EVENT_EMPTY, function(){ + this.editor.on(BI.Editor.EVENT_EMPTY, function () { self.fireEvent(BI.RecordEditor.EVENT_EMPTY, arguments); }); BI.createWidget({ @@ -2681,41 +3054,41 @@ BI.RecordEditor = BI.inherit(BI.Single, { element: this, items: [this.textContainer, this.editor] }); - BI.Resizers.add(this.getName(), BI.bind(this._adjustInputWidth, this)); + BI.ResizeDetector.addResizeListener(this, BI.bind(this._adjustInputWidth, this)); this._adjustInputWidth(); }, - _adjustInputWidth: function(){ - BI.nextTick(BI.bind(function(){ + _adjustInputWidth: function () { + BI.nextTick(BI.bind(function () { this.editor.element.css("width", this.element.width() - this.textContainer.element.outerWidth() - 10); }, this)); }, - _checkInputState: function(){ - if(BI.isEmpty(this.contents)){ + _checkInputState: function () { + if (BI.isEmpty(this.contents)) { this.editor.enableWarterMark(); } else { this.editor.disableWarterMark(); } }, - focus: function(){ + focus: function () { this.editor.focus(); }, - blur: function(){ + blur: function () { this.editor.blur(); }, - isValid : function() { + isValid: function () { return this.editor.isValid(); }, - setErrorText: function(text){ + setErrorText: function (text) { this.editor.setErrorText(text); }, - getErrorText: function(){ + getErrorText: function () { return this.editor.getErrorText(); }, @@ -2735,21 +3108,21 @@ BI.RecordEditor = BI.inherit(BI.Single, { return this.editor.getValue(); }, - getState: function(){ - var values = BI.map(this.contents, function(i, lb){ + getState: function () { + var values = BI.map(this.contents, function (i, lb) { return lb.getText(); }); - if(BI.isNotEmptyString(this.editor.getValue())){ + if (BI.isNotEmptyString(this.editor.getValue())) { return values.concat([this.editor.getValue()]); } return values; }, - setState: function(v){ - BI.StateEditor.superclass.setValue.apply(this, arguments); - v = BI.isArray(v) ? v : (v == "" ? [] : [v]); + setState: function (v) { + BI.RecordEditor.superclass.setValue.apply(this, arguments); + v = BI.isArray(v) ? v : (v == "" ? [] : [v]); var contents = this.contents = []; - BI.each(v, function(i, lb){ + BI.each(v, function (i, lb) { contents.push(BI.createWidget({ type: "bi.label", height: 25, @@ -2764,7 +3137,7 @@ BI.RecordEditor = BI.inherit(BI.Single, { this._adjustInputWidth(); }, - destroy: function(){ + destroy: function () { BI.Resizers.remove(this.getName()); BI.RecordEditor.superclass.destroy.apply(this, arguments); } @@ -2995,6 +3368,10 @@ BI.ShelterEditor = BI.inherit(BI.Single, { return this.editor.getLastValidValue(); }, + setTextStyle: function (style) { + this.text.setStyle(style); + }, + setValue: function (k) { this.editor.setValue(k); this._checkText(); @@ -3170,13 +3547,15 @@ BI.SignEditor = BI.inherit(BI.Single, { _checkText: function () { var o = this.options; - if (this.editor.getValue() === "") { - this.text.setValue(o.watermark || ""); - this.text.element.addClass("bi-water-mark"); - } else { - this.text.setValue(this.editor.getValue()); - this.text.element.removeClass("bi-water-mark"); - } + BI.nextTick(BI.bind(function () { + if (this.editor.getValue() === "") { + this.text.setValue(o.watermark || ""); + this.text.element.addClass("bi-water-mark"); + } else { + this.text.setValue(this.editor.getValue()); + this.text.element.removeClass("bi-water-mark"); + } + }, this)); }, _showInput: function () { @@ -3441,8 +3820,10 @@ BI.StateEditor = BI.inherit(BI.Single, { }, focus: function () { - this._showInput(); - this.editor.focus(); + if (this.options.disabled === false) { + this._showInput(); + this.editor.focus(); + } }, blur: function () { @@ -3484,6 +3865,11 @@ BI.StateEditor = BI.inherit(BI.Single, { this.editor.setValue(k); }, + setEnable: function (v) { + this.text.setEnable(v); + this.editor.setEnable(v); + }, + getValue: function () { return this.editor.getValue(); }, @@ -3497,26 +3883,44 @@ BI.StateEditor = BI.inherit(BI.Single, { if (BI.isNumber(v)) { if (v === BI.Selection.All) { this.text.setText(BI.i18nText("BI-Select_All")); + this.text.setTitle(""); this.text.element.removeClass("state-editor-infinite-text"); } else if (v === BI.Selection.Multi) { this.text.setText(BI.i18nText("BI-Select_Part")); + this.text.setTitle(""); this.text.element.removeClass("state-editor-infinite-text"); } else { this.text.setText(BI.i18nText("BI-Unrestricted")); + this.text.setTitle(""); this.text.element.addClass("state-editor-infinite-text"); } return; } - if (!BI.isArray(v) || v.length === 1) { - this.text.setText(v); - this.text.setTitle(v); - this.text.element.removeClass("state-editor-infinite-text"); - } else if (BI.isEmpty(v)) { - this.text.setText(BI.i18nText("BI-Unrestricted")); - this.text.element.addClass("state-editor-infinite-text"); - } else { - this.text.setText(BI.i18nText("BI-Select_Part")); - this.text.element.removeClass("state-editor-infinite-text"); + if (BI.isString(v)) { + if (BI.isEmpty(v)) { + this.text.setText(BI.i18nText("BI-Unrestricted")); + this.text.setTitle(""); + this.text.element.addClass("state-editor-infinite-text"); + } else { + this.text.setText(v); + this.text.setTitle(v); + this.text.element.removeClass("state-editor-infinite-text"); + } + return; + } + if (BI.isArray(v)) { + if (BI.isEmpty(v)) { + this.text.setText(BI.i18nText("BI-Unrestricted")); + this.text.element.addClass("state-editor-infinite-text"); + } else if (v.length === 1) { + this.text.setText(v[0]); + this.text.setTitle(v[0]); + this.text.element.removeClass("state-editor-infinite-text"); + } else { + this.text.setText(BI.i18nText("BI-Select_Part")); + this.text.setTitle(""); + this.text.element.removeClass("state-editor-infinite-text"); + } } } }); @@ -3739,6 +4143,11 @@ BI.SimpleStateEditor = BI.inherit(BI.Single, { this.editor.setValue(k); }, + setEnable: function(v){ + this.text.setEnable(v); + this.editor.setEnable(v); + }, + getValue: function () { return this.editor.getValue(); }, @@ -3751,10 +4160,10 @@ BI.SimpleStateEditor = BI.inherit(BI.Single, { BI.SimpleStateEditor.superclass.setValue.apply(this, arguments); if (BI.isNumber(v)) { if (v === BI.Selection.All) { - this.text.setText(BI.i18nText("BI-Aleady_Selected")); + this.text.setText(BI.i18nText("BI-Already_Selected")); this.text.element.removeClass("state-editor-infinite-text"); } else if (v === BI.Selection.Multi) { - this.text.setText(BI.i18nText("BI-Aleady_Selected")); + this.text.setText(BI.i18nText("BI-Already_Selected")); this.text.element.removeClass("state-editor-infinite-text"); } else { this.text.setText(BI.i18nText("BI-Unrestricted")); @@ -3770,7 +4179,7 @@ BI.SimpleStateEditor = BI.inherit(BI.Single, { this.text.setText(BI.i18nText("BI-Unrestricted")); this.text.element.addClass("state-editor-infinite-text"); } else { - this.text.setText(BI.i18nText("BI-Aleady_Selected")); + this.text.setText(BI.i18nText("BI-Already_Selected")); this.text.element.removeClass("state-editor-infinite-text"); } } @@ -3920,7 +4329,7 @@ $.shortcut("bi.branch_expander", BI.BranchExpander);/** BI.BarFloatSection = BI.inherit(BI.FloatSection, { _defaultConfig: function () { return BI.extend(BI.BarFloatSection.superclass._defaultConfig.apply(this, arguments), { - btns: [BI.i18nText(BI.i18nText("BI-Sure")), BI.i18nText("BI-Cancel")] + btns: [BI.i18nText(BI.i18nText("BI-Basic_Sure")), BI.i18nText("BI-Basic_Cancel")] }) }, @@ -3986,7 +4395,7 @@ BI.BarFloatSection = BI.inherit(BI.FloatSection, { BI.BarPopoverSection = BI.inherit(BI.PopoverSection, { _defaultConfig: function () { return BI.extend(BI.BarPopoverSection.superclass._defaultConfig.apply(this, arguments), { - btns: [BI.i18nText(BI.i18nText("BI-Sure")), BI.i18nText(BI.i18nText("BI-Cancel"))] + btns: [BI.i18nText(BI.i18nText("BI-Basic_Sure")), BI.i18nText(BI.i18nText("BI-Basic_Cancel"))] }) }, @@ -3995,10 +4404,11 @@ BI.BarPopoverSection = BI.inherit(BI.PopoverSection, { }, rebuildSouth: function (south) { - var self = this; + var self = this, o = this.options; this.sure = BI.createWidget({ type: 'bi.button', text: this.options.btns[0], + warningTitle: o.warningTitle, height: 30, value: 0, handler: function (v) { @@ -4022,6 +4432,10 @@ BI.BarPopoverSection = BI.inherit(BI.PopoverSection, { hgap: 5, items: [this.cancel, this.sure] }); + }, + + setConfirmButtonEnable: function(v){ + this.sure.setEnable(!!v); } });/** * 下拉框弹出层的多选版本,toolbar带有若干按钮, zIndex在1000w @@ -4035,7 +4449,7 @@ BI.MultiPopupView = BI.inherit(BI.PopupView, { var conf = BI.MultiPopupView.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-multi-list-view", - buttons: [BI.i18nText("BI-Sure")] + buttons: [BI.i18nText("BI-Basic_Sure")] }) }, @@ -5077,38 +5491,277 @@ BI.SortList = BI.inherit(BI.Widget, { }); BI.SortList.EVENT_CHANGE = "EVENT_CHANGE"; $.shortcut("bi.sort_list", BI.SortList);/** - * 有总页数的分页控件 - * - * Created by GUY on 2015/9/8. - * @class BI.AllPagger - * @extends BI.Widget + * Created by Young's on 2016/8/30. */ -BI.AllPagger = BI.inherit(BI.Widget, { - +BI.LoginTimeOut = BI.inherit(BI.BarPopoverSection, { _defaultConfig: function () { - return BI.extend(BI.AllPagger.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-all-pager", - width: 96, - height: 25, - pages: 1, //必选项 - curr: 1 //初始化当前页, pages为数字时可用 - }) + return BI.extend(BI.LoginTimeOut.superclass._defaultConfig.apply(this, arguments), {}) }, + _init: function () { - BI.AllPagger.superclass._init.apply(this, arguments); + BI.LoginTimeOut.superclass._init.apply(this, arguments); + }, + + rebuildNorth: function (north) { + BI.createWidget({ + type: "bi.label", + element: north, + text: BI.i18nText("BI-Login_Timeout"), + height: 50, + textAlign: "left" + }) + }, + + rebuildCenter: function (center) { + var self = this, o = this.options; + var userNameInput = BI.createWidget({ + type: "bi.editor", + watermark: BI.i18nText("BI-Username"), + cls: "login-input", + allowBlank: true, + width: 300, + height: 30 + }); + var userNameMask = BI.createWidget({ + type: "bi.text_button", + width: 330, + height: 56, + cls: "error-mask" + }); + userNameMask.setVisible(false); + userNameMask.on(BI.TextButton.EVENT_CHANGE, function () { + userNameInput.focus(); + this.element.fadeOut(); + }); + + var userNameWrapper = BI.createWidget({ + type: "bi.absolute", + cls: "input-wrapper login-username-icon", + items: [{ + el: { + type: "bi.icon", + width: 26, + height: 26 + }, + top: 10, + left: 0 + }, { + el: userNameInput, + top: 8, + left: 30 + }, { + el: userNameMask, + top: 0, + left: 0 + }], + width: 330, + height: 56 + }); + + + var passwordInput = BI.createWidget({ + type: "bi.editor", + inputType: "password", + cls: "login-input", + allowBlank: true, + watermark: BI.i18nText("BI-Basic_Password"), + width: 300, + height: 30 + }); + var passwordMask = BI.createWidget({ + type: "bi.text_button", + width: 330, + height: 56, + cls: "error-mask" + }); + passwordMask.setVisible(false); + passwordMask.on(BI.TextButton.EVENT_CHANGE, function () { + passwordInput.focus(); + this.element.fadeOut(); + }); + + var passwordWrapper = BI.createWidget({ + type: "bi.absolute", + cls: "input-wrapper login-password-icon", + items: [{ + el: { + type: "bi.icon", + width: 26, + height: 26 + }, + top: 10, + left: 0 + }, { + el: passwordInput, + top: 8, + left: 30 + }, { + el: passwordMask, + top: 0, + left: 0 + }], + width: 330, + height: 56 + }); + + var loginButton = BI.createWidget({ + type: "bi.text_button", + text: BI.i18nText("BI-Basic_Login"), + cls: "login-button", + width: 330, + height: 50 + }); + loginButton.on(BI.TextButton.EVENT_CHANGE, function () { + if (BI.isEmptyString(userNameInput.getValue())) { + self._showMes(userNameMask, BI.i18nText("BI-Username_Not_Null")); + return; + } + if (BI.isEmptyString(passwordInput.getValue())) { + self._showMes(passwordMask, BI.i18nText("BI-Password_Not_Null")); + return; + } + + //反正是登录直接用FR的登录了 + FR.ajax({ + url: FR.servletURL + '?op=fs_load&cmd=login', + data: FR.cjkEncodeDO({ + fr_username: encodeURIComponent(userNameInput.getValue()), + fr_password: encodeURIComponent(passwordInput.getValue()), + fr_remember: self.keepLoginState.isSelected() + }), + type: 'POST', + async: false, + error: function () { + BI.Msg.toast("Error!"); + }, + complete: function (res, status) { + if (BI.isEmptyString(res.responseText)) { + self._showMes(userNameMask, BI.i18nText("BI-Authentication_Failed")); + return; + } + var signResult = FR.jsonDecode(res.responseText); + if (signResult.fail) { + //用户名和密码不匹配 + self._showMes(userNameMask, BI.i18nText("BI-Username_Password_Not_Correct")); + } else if (signResult.url) { + self.fireEvent(BI.LoginTimeOut.EVENT_LOGIN); + } + } + }); + }); + + var logo; + if (BI.isNotNull(window.top.FS)) { + logo = window.top.FS.config.logoImageID4FS; + } + BI.createWidget({ + type: "bi.absolute", + element: center, + cls: "bi-login-timeout-center", + items: [{ + el: { + type: "bi.center_adapt", + items: [{ + type: "bi.img", + src: FR.servletURL + (logo ? + '?op=fr_attach&cmd=ah_image&id=' + logo + '&isAdjust=false' : + '?op=resource&resource=/com/fr/bi/web/images/login/bi_logo.png'), + width: 120, + height: 120 + }], + width: 200, + height: 300 + }, + left: 0, + top: 0 + }, { + el: userNameWrapper, + top: 30, + left: 230 + }, { + el: passwordWrapper, + top: 100, + left: 230 + }, { + el: loginButton, + top: 200, + left: 230 + }] + }); + }, + + _showMes: function (widget, mes) { + widget.setText(mes); + widget.element.fadeIn(); + setTimeout(function () { + if (widget.element.isVisible()) { + widget.element.fadeOut(); + } + }, 5000); + }, + + rebuildSouth: function (south) { + this.keepLoginState = BI.createWidget({ + type: "bi.checkbox", + width: 16, + height: 16 + }); + BI.createWidget({ + type: "bi.absolute", + element: south, + cls: "bi-login-timeout-south", + items: [{ + el: this.keepLoginState, + top: 0, + left: 230 + }, { + el: { + type: "bi.label", + text: BI.i18nText("BI-Keep_Login_State"), + cls: "keep-state", + height: 30 + }, + top: -7, + left: 260 + }] + }) + } +}); +BI.extend(BI.LoginTimeOut, { + POPOVER_ID: "___popover__id___" +}); +BI.LoginTimeOut.EVENT_LOGIN = "EVENT_LOGIN"; +$.shortcut("bi.login_timeout", BI.LoginTimeOut); +/** + * 有总页数和总行数的分页控件 + * Created by Young's on 2016/10/13. + */ +BI.AllCountPager = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.AllCountPager.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-all-count-pager", + height: 30, + pages: 1, //必选项 + curr: 1, //初始化当前页, pages为数字时可用, + count: 1 //总行数 + }) + }, + _init: function () { + BI.AllCountPager.superclass._init.apply(this, arguments); var self = this, o = this.options; this.editor = BI.createWidget({ type: "bi.small_text_editor", cls: "pager-editor", validationChecker: function (v) { - return BI.isPositiveInteger(v); + return (self.rowCount.getValue() === 0 && v === "0") || BI.isPositiveInteger(v); }, hgap: 4, vgap: 0, value: o.curr, errorText: BI.i18nText("BI-Please_Input_Integer"), width: 30, - height: o.height - 2 + height: 20 }); this.pager = BI.createWidget({ type: "bi.pager", @@ -5131,7 +5784,7 @@ BI.AllPagger = BI.inherit(BI.Widget, { value: "prev", title: BI.i18nText("BI-Previous_Page"), warningTitle: BI.i18nText("BI-Current_Is_First_Page"), - height: o.height - 2, + height: 20, cls: "all-pager-prev column-pre-page-h-font" }, next: { @@ -5139,7 +5792,7 @@ BI.AllPagger = BI.inherit(BI.Widget, { value: "next", title: BI.i18nText("BI-Next_Page"), warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), - height: o.height - 2, + height: 20, cls: "all-pager-next column-next-page-h-font" }, @@ -5151,10 +5804,10 @@ BI.AllPagger = BI.inherit(BI.Widget, { this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { self.pager.setValue(BI.parseInt(self.editor.getValue())); - self.fireEvent(BI.AllPagger.EVENT_CHANGE); + self.fireEvent(BI.AllCountPager.EVENT_CHANGE); }); this.pager.on(BI.Pager.EVENT_CHANGE, function () { - self.fireEvent(BI.AllPagger.EVENT_CHANGE); + self.fireEvent(BI.AllCountPager.EVENT_CHANGE); }); this.pager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { self.editor.setValue(self.pager.getCurrentPage()); @@ -5167,11 +5820,34 @@ BI.AllPagger = BI.inherit(BI.Widget, { text: "/" + o.pages }); + this.rowCount = BI.createWidget({ + type: "bi.label", + height: o.height, + hgap: 5, + text: o.count, + title: o.count + }); + + var count = BI.createWidget({ + type: "bi.left", + items: [{ + type: "bi.label", + height: o.height, + text: BI.i18nText("BI-Basic_Total"), + width: 15 + }, this.rowCount, { + type: "bi.label", + height: o.height, + text: BI.i18nText("BI-Tiao_Data"), + width: 50, + textAlign: "left" + }] + }); BI.createWidget({ type: "bi.center_adapt", element: this, - columnSize: [30, "", 36], - items: [this.editor, this.allPages, this.pager] + columnSize: ["", 30, 40, 36], + items: [count, this.editor, this.allPages, this.pager] }) }, @@ -5179,12 +5855,18 @@ BI.AllPagger = BI.inherit(BI.Widget, { this.allPages.setText("/" + v); this.allPages.setTitle(v); this.pager.setAllPages(v); + this.editor.setEnable(v >= 1); }, setValue: function (v) { this.pager.setValue(v); }, + setCount: function (count) { + this.rowCount.setText(count); + this.rowCount.setTitle(count); + }, + getCurrentPage: function () { return this.pager.getCurrentPage(); }, @@ -5197,12 +5879,22 @@ BI.AllPagger = BI.inherit(BI.Widget, { return this.pager.hasNext(); }, + setPagerVisible: function (b) { + this.editor.setVisible(b); + this.allPages.setVisible(b); + this.pager.setVisible(b); + }, + + getAliasWidth: function () { + return this.options.width - 100; + }, + populate: function () { this.pager.populate(); } }); -BI.AllPagger.EVENT_CHANGE = "EVENT_CHANGE"; -$.shortcut("bi.all_pager", BI.AllPagger);/** +BI.AllCountPager.EVENT_CHANGE = "EVENT_CHANGE"; +$.shortcut("bi.all_count_pager", BI.AllCountPager);/** * 显示页码的分页控件 * * Created by GUY on 2016/6/30. @@ -5214,8 +5906,7 @@ BI.DirectionPager = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.DirectionPager.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-direction-pager", - width: 108, - height: 25, + height: 30, horizontal: { pages: false, //总页数 curr: 1, //初始化当前页, pages为数字时可用 @@ -5242,26 +5933,26 @@ BI.DirectionPager = BI.inherit(BI.Widget, { var v = o.vertical, h = o.horizontal; this._createVPager(); this._createHPager(); - BI.createWidget({ + this.layout = BI.createWidget({ type: "bi.absolute", scrollable: false, element: this, items: [{ el: this.vpager, - top: 0, - left: -19 + top: 5, + right: 74 }, { el: this.vlabel, - top: 0, - left: 16 + top: 5, + right: 111 }, { el: this.hpager, - top: 0, - right: -19 + top: 5, + right: -9 }, { el: this.hlabel, - top: 0, - right: 16 + top: 5, + right: 28 }] }); }, @@ -5271,17 +5962,18 @@ BI.DirectionPager = BI.inherit(BI.Widget, { var v = o.vertical; this.vlabel = BI.createWidget({ type: "bi.label", - width: 20, - height: o.height, + width: 24, + height: 20, value: v.curr, title: v.curr }); this.vpager = BI.createWidget({ type: "bi.pager", - width: 72, + width: 76, layouts: [{ type: "bi.horizontal", - lgap: 20, + scrollx: false, + rgap: 24, vgap: 1 }], @@ -5297,9 +5989,9 @@ BI.DirectionPager = BI.inherit(BI.Widget, { value: "prev", title: BI.i18nText("BI-Up_Page"), warningTitle: BI.i18nText("BI-Current_Is_First_Page"), - height: o.height - 2, - iconWidth: o.height - 2, - iconHeight: o.height - 2, + height: 20, + iconWidth: 16, + iconHeight: 16, cls: "direction-pager-prev column-pre-page-h-font" }, next: { @@ -5307,9 +5999,9 @@ BI.DirectionPager = BI.inherit(BI.Widget, { value: "next", title: BI.i18nText("BI-Down_Page"), warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), - height: o.height - 2, - iconWidth: o.height - 2, - iconHeight: o.height - 2, + height: 20, + iconWidth: 16, + iconHeight: 16, cls: "direction-pager-next column-next-page-h-font" }, @@ -5324,6 +6016,7 @@ BI.DirectionPager = BI.inherit(BI.Widget, { }); this.vpager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { self.vlabel.setValue(this.getCurrentPage()); + self.vlabel.setTitle(this.getCurrentPage()); }); }, @@ -5332,17 +6025,18 @@ BI.DirectionPager = BI.inherit(BI.Widget, { var h = o.horizontal; this.hlabel = BI.createWidget({ type: "bi.label", - width: 20, - height: o.height, + width: 24, + height: 20, value: h.curr, title: h.curr }); this.hpager = BI.createWidget({ type: "bi.pager", - width: 72, + width: 76, layouts: [{ type: "bi.horizontal", - rgap: 20, + scrollx: false, + rgap: 24, vgap: 1 }], @@ -5358,9 +6052,9 @@ BI.DirectionPager = BI.inherit(BI.Widget, { value: "prev", title: BI.i18nText("BI-Left_Page"), warningTitle: BI.i18nText("BI-Current_Is_First_Page"), - height: o.height - 2, - iconWidth: o.height - 2, - iconHeight: o.height - 2, + height: 20, + iconWidth: 16, + iconHeight: 16, cls: "direction-pager-prev row-pre-page-h-font" }, next: { @@ -5368,9 +6062,9 @@ BI.DirectionPager = BI.inherit(BI.Widget, { value: "next", title: BI.i18nText("BI-Right_Page"), warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), - height: o.height - 2, - iconWidth: o.height - 2, - iconHeight: o.height - 2, + height: 20, + iconWidth: 16, + iconHeight: 16, cls: "direction-pager-next row-next-page-h-font" }, @@ -5385,6 +6079,7 @@ BI.DirectionPager = BI.inherit(BI.Widget, { }); this.hpager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { self.hlabel.setValue(this.getCurrentPage()); + self.hlabel.setTitle(this.getCurrentPage()); }); }, @@ -5437,241 +6132,332 @@ BI.DirectionPager = BI.inherit(BI.Widget, { populate: function () { this.vpager.populate(); this.hpager.populate(); + var vShow = false, hShow = false; + if (!this.hasHNext() && !this.hasHPrev()) { + this.setHPagerVisible(false); + } else { + this.setHPagerVisible(true); + hShow = true; + } + if (!this.hasVNext() && !this.hasVPrev()) { + this.setVPagerVisible(false); + } else { + this.setVPagerVisible(true); + vShow = true; + } + var num = [74, 111, -9, 28]; + var items = this.layout.attr("items"); + + if (vShow === true && hShow === true) { + items[0].right = num[0]; + items[1].right = num[1]; + items[2].right = num[2]; + items[3].right = num[3]; + } else if (vShow === true) { + items[0].right = num[2]; + items[1].right = num[3]; + } else if (hShow === true) { + items[2].right = num[2]; + items[3].right = num[3]; + } + this.layout.attr("items", items); + this.layout.resize(); }, - - refresh: function () { - this.vpager.refresh(); - this.hpager.refresh(); + + clear: function () { + this.vpager.attr("curr", 1); + this.hpager.attr("curr", 1); } }); BI.DirectionPager.EVENT_CHANGE = "EVENT_CHANGE"; $.shortcut("bi.direction_pager", BI.DirectionPager);/** - * 显示页码的分页控件 + * 分页控件 * - * Created by GUY on 2016/2/17. - * @class BI.NumberPager + * Created by GUY on 2015/8/31. + * @class BI.DetailPager * @extends BI.Widget */ -BI.NumberPager = BI.inherit(BI.Widget, { - +BI.DetailPager = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.NumberPager.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-number-pager", - width: 95, - height: 25, + return BI.extend(BI.DetailPager.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-detail-pager", + behaviors: {}, + layouts: [{ + type: "bi.horizontal", + hgap: 10, + vgap: 0 + }], + + dynamicShow: true, //是否动态显示上一页、下一页、首页、尾页, 若为false,则指对其设置使能状态 + //dynamicShow为false时以下两个有用 + dynamicShowFirstLast: false,//是否动态显示首页、尾页 + dynamicShowPrevNext: false,//是否动态显示上一页、下一页 pages: false, //总页数 - curr: 1, //初始化当前页, pages为数字时可用 + curr: function () { + return 1; + }, //初始化当前页 + groups: 0, //连续显示分页数 + jump: BI.emptyFn, //分页的回调函数 + + first: false, //是否显示首页 + last: false, //是否显示尾页 + prev: "上一页", + next: "下一页", - hasPrev: BI.emptyFn, - hasNext: BI.emptyFn, firstPage: 1, - lastPage: BI.emptyFn + lastPage: function () { //在万不得已时才会调用这个函数获取最后一页的页码, 主要作用于setValue方法 + return 1; + }, + hasPrev: BI.emptyFn, //pages不可用时有效 + hasNext: BI.emptyFn //pages不可用时有效 }) }, _init: function () { - BI.NumberPager.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.currentPage = o.curr; - this.label = BI.createWidget({ - type: "bi.label", - height: o.height - 2, - value: this.currentPage - }); - this.pager = BI.createWidget({ - type: "bi.pager", - width: 36, - layouts: [{ - type: "bi.horizontal", - hgap: 1, - vgap: 1 - }], + BI.DetailPager.superclass._init.apply(this, arguments); + var self = this; + this.currPage = BI.result(this.options, "curr"); + //翻页太灵敏 + this._lock = false; + this._debouce = BI.debounce(function () { + self._lock = false; + }, 300); + this._populate(); + }, - dynamicShow: false, - pages: o.pages, - curr: o.curr, - groups: 0, + _populate: function () { + var self = this, o = this.options, view = [], dict = {}; + this.empty(); + var pages = BI.result(o, "pages"); + var curr = BI.result(this, "currPage"); + var groups = BI.result(o, "groups"); + var first = BI.result(o, "first"); + var last = BI.result(o, "last"); + var prev = BI.result(o, "prev"); + var next = BI.result(o, "next"); + + if (pages === false) { + groups = 0; + first = false; + last = false; + } else { + groups > pages && (groups = pages); + } - first: false, - last: false, - prev: { - type: "bi.icon_button", - value: "prev", - title: BI.i18nText("BI-Previous_Page"), - warningTitle: BI.i18nText("BI-Current_Is_First_Page"), - height: o.height - 2, - iconWidth: o.height - 2, - iconHeight: o.height - 2, - cls: "number-pager-prev column-pre-page-h-font" - }, - next: { - type: "bi.icon_button", - value: "next", - title: BI.i18nText("BI-Next_Page"), - warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), - height: o.height - 2, - iconWidth: o.height - 2, - iconHeight: o.height - 2, - cls: "number-pager-next column-next-page-h-font" - }, + //计算当前组 + dict.index = Math.ceil((curr + ((groups > 1 && groups !== pages) ? 1 : 0)) / (groups === 0 ? 1 : groups)); - hasPrev: o.hasPrev, - hasNext: o.hasNext, - firstPage: o.firstPage, - lastPage: o.lastPage - }); + //当前页非首页,则输出上一页 + if (((!o.dynamicShow && !o.dynamicShowPrevNext) || curr > 1) && prev !== false) { + if (BI.isKey(prev)) { + view.push({ + text: prev, + value: "prev", + disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false) + }) + } else { + view.push(BI.extend({ + disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false) + }, prev)); + } + } - this.pager.on(BI.Pager.EVENT_CHANGE, function () { - if (self.getCurrentPage() !== self.pager.getCurrentPage()) { - self.currentPage = self.pager.getCurrentPage(); - self.fireEvent(BI.NumberPager.EVENT_CHANGE); + //当前组非首组,则输出首页 + if (((!o.dynamicShow && !o.dynamicShowFirstLast) || (dict.index > 1 && groups !== 0)) && first) { + view.push({ + text: first, + value: "first", + disabled: !(dict.index > 1 && groups !== 0) + }); + if (dict.index > 1 && groups !== 0) { + view.push({ + type: "bi.label", + cls: "page-ellipsis", + text: "\u2026" + }); } - }); - this.pager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { - self.label.setValue(self.pager.getCurrentPage()); - }); + } - BI.createWidget({ - type: "bi.center_adapt", + //输出当前页组 + dict.poor = Math.floor((groups - 1) / 2); + dict.start = dict.index > 1 ? curr - dict.poor : 1; + dict.end = dict.index > 1 ? (function () { + var max = curr + (groups - dict.poor - 1); + return max > pages ? pages : max; + }()) : groups; + if (dict.end - dict.start < groups - 1) { //最后一组状态 + dict.start = dict.end - groups + 1; + } + var s = dict.start, e = dict.end; + if (first && last && (dict.index > 1 && groups !== 0) && (pages > groups && dict.end < pages && groups !== 0)) { + s++; + e--; + } + for (; s <= e; s++) { + if (s === curr) { + view.push({ + text: s, + value: s, + selected: true + }) + } else { + view.push({ + text: s, + value: s + }) + } + } + + //总页数大于连续分页数,且当前组最大页小于总页,输出尾页 + if (((!o.dynamicShow && !o.dynamicShowFirstLast) || (pages > groups && dict.end < pages && groups !== 0)) && last) { + if (pages > groups && dict.end < pages && groups !== 0) { + view.push({ + type: "bi.label", + cls: "page-ellipsis", + text: "\u2026" + }); + } + view.push({ + text: last, + value: "last", + disabled: !(pages > groups && dict.end < pages && groups !== 0) + }) + } + + //当前页不为尾页时,输出下一页 + dict.flow = !prev && groups === 0; + if (((!o.dynamicShow && !o.dynamicShowPrevNext) && next) || (curr !== pages && next || dict.flow)) { + view.push((function () { + if (BI.isKey(next)) { + if (pages === false) { + return {text: next, value: "next", disabled: o.hasNext(curr) === false} + } + return (dict.flow && curr === pages) + ? + {text: next, value: "next", disabled: true} + : + {text: next, value: "next", disabled: !(curr !== pages && next || dict.flow)}; + } else { + return BI.extend({ + disabled: pages === false ? o.hasNext(curr) === false : !(curr !== pages && next || dict.flow) + }, next); + } + }())); + } + + this.button_group = BI.createWidget({ + type: "bi.button_group", element: this, - columnSize: [20, "", 20, 36], - items: [{type: "bi.label", text: "第"}, this.label, {type: "bi.label", text: "页"}, this.pager] - }) + items: BI.createItems(view, { + cls: "page-item", + height: 23, + hgap: 10 + }), + behaviors: o.behaviors, + layouts: o.layouts + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { + if (self._lock === true) { + return; + } + self._lock = true; + self._debouce(); + if (type === BI.Events.CLICK) { + var v = self.button_group.getValue()[0]; + switch (v) { + case "first": + self.currPage = 1; + break; + case "last": + self.currPage = pages; + break; + case "prev": + self.currPage--; + break; + case "next": + self.currPage++; + break; + default: + self.currPage = v; + break; + } + o.jump.apply(self, [{ + pages: pages, + curr: self.currPage + }]); + self._populate(); + self.fireEvent(BI.DetailPager.EVENT_CHANGE, obj); + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.fireEvent(BI.DetailPager.EVENT_AFTER_POPULATE); }, getCurrentPage: function () { - return this.currentPage; + return this.currPage; }, - hasPrev: function () { - return this.pager.hasPrev(); + setAllPages: function (pages) { + this.options.pages = pages; }, - hasNext: function () { - return this.pager.hasNext(); + hasPrev: function (v) { + v || (v = 1); + var o = this.options; + var pages = this.options.pages; + return pages === false ? o.hasPrev(v) : v > 1; + }, + + hasNext: function (v) { + v || (v = 1); + var o = this.options; + var pages = this.options.pages; + return pages === false ? o.hasNext(v) : v < pages; }, setValue: function (v) { - this.currentPage = v; - this.pager.setValue(v); + var o = this.options; + v = v | 0; + v = v < 1 ? 1 : v; + if (o.pages === false) { + var lastPage = BI.result(o, "lastPage"), firstPage = 1; + this.currPage = v > lastPage ? lastPage : ((firstPage = BI.result(o, "firstPage")), (v < firstPage ? firstPage : v)); + } else { + v = v > o.pages ? o.pages : v; + this.currPage = v; + } + this._populate(); }, - populate: function () { - this.pager.populate(); - } -}); -BI.NumberPager.EVENT_CHANGE = "EVENT_CHANGE"; -$.shortcut("bi.number_pager", BI.NumberPager);/** - * 可以跳转的分页控件 - * - * Created by GUY on 2015/9/8. - * @class BI.SkipPager - * @extends BI.Widget - */ -BI.SkipPager = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SkipPager.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-skip-pager", - width: 110, - height: 25, - pages: false, //总页数 - curr: 1, //初始化当前页, pages为数字时可用 - - hasPrev: BI.emptyFn, - hasNext: BI.emptyFn, - firstPage: 1, - lastPage: BI.emptyFn - }) - }, - _init: function () { - BI.SkipPager.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.currentPage = o.curr; - this.editor = BI.createWidget({ - type: "bi.small_text_editor", - validationChecker: function (v) { - return BI.isPositiveInteger(v); - }, - hgap: 4, - vgap: 0, - value: o.curr, - errorText: BI.i18nText("BI-Please_Input_Integer"), - width: 30, - height: o.height - 2 - }); - this.pager = BI.createWidget({ - type: "bi.pager", - layouts: [{ - type: "bi.horizontal", - hgap: 1, - vgap: 1 - }], - - dynamicShow: false, - pages: o.pages, - curr: o.curr, - groups: 0, - - first: false, - last: false, - prev: { - type: "bi.icon_button", - value: "prev", - title: BI.i18nText("BI-Previous_Page"), - warningTitle: BI.i18nText("BI-Current_Is_First_Page"), - height: o.height - 2, - cls: "number-pager-prev column-pre-page-h-font" - }, - next: { - type: "bi.icon_button", - value: "next", - title: BI.i18nText("BI-Next_Page"), - warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), - height: o.height - 2, - cls: "number-pager-next column-next-page-h-font" - }, - - hasPrev: o.hasPrev, - hasNext: o.hasNext, - firstPage: o.firstPage, - lastPage: o.lastPage - }); - - this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { - self.pager.setValue(self.editor.getValue()); - }); - this.pager.on(BI.Pager.EVENT_CHANGE, function () { - if (self.getCurrentPage() !== self.pager.getCurrentPage()) { - self.currentPage = self.pager.getCurrentPage(); - self.fireEvent(BI.SkipPager.EVENT_CHANGE); - } - }); - this.pager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { - self.editor.setValue(self.pager.getCurrentPage()); - }); - - BI.createWidget({ - type: "bi.center_adapt", - element: this, - items: [{type: "bi.label", text: "第"}, this.editor, {type: "bi.label", text: "页"}, this.pager] - }) - }, - - getCurrentPage: function () { - return this.currentPage; + getValue: function () { + var val = this.button_group.getValue()[0]; + switch (val) { + case "prev": + return -1; + case "next": + return 1; + case "first": + return BI.MIN; + case "last": + return BI.MAX; + default : + return val; + } }, - setValue: function(v){ - this.currentPage = v; - this.pager.setValue(v); + attr: function (key, value) { + BI.DetailPager.superclass.attr.apply(this, arguments); + if (key === "curr") { + this.currPage = BI.result(this.options, "curr"); + } }, populate: function () { - this.pager.populate(); + this._populate(); } }); -BI.SkipPager.EVENT_CHANGE = "EVENT_CHANGE"; -$.shortcut("bi.skip_pager", BI.SkipPager);/** +BI.DetailPager.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DetailPager.EVENT_AFTER_POPULATE = "EVENT_AFTER_POPULATE"; +$.shortcut("bi.detail_pager", BI.DetailPager);/** * 分段控件使用的button * * Created by GUY on 2015/9/7. @@ -5778,6 +6564,240 @@ BI.Segment = BI.inherit(BI.Widget, { }); BI.Segment.EVENT_CHANGE = "EVENT_CHANGE"; $.shortcut('bi.segment', BI.Segment);/** + * 自适应宽度的表格 + * + * Created by GUY on 2016/2/3. + * @class BI.AdaptiveTable + * @extends BI.Widget + */ +BI.AdaptiveTable = BI.inherit(BI.Widget, { + + _const: { + perColumnSize: 100 + }, + + _defaultConfig: function () { + return BI.extend(BI.AdaptiveTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-adaptive-table", + el: { + type: "bi.resizable_table" + }, + isNeedResize: true, + isNeedFreeze: false,//是否需要冻结单元格 + freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 + + isNeedMerge: false,//是否需要合并单元格 + mergeCols: [], //合并的单元格列号 + mergeRule: BI.emptyFn, + + columnSize: [], + minColumnSize: [], + maxColumnSize: [], + + headerRowSize: 25, + rowSize: 25, + + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [] + }); + }, + + _init: function () { + BI.AdaptiveTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var data = this._digest(); + this.table = BI.createWidget(o.el, { + type: "bi.resizable_table", + element: this, + width: o.width, + height: o.height, + isNeedResize: o.isNeedResize, + isResizeAdapt: false, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: data.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: data.columnSize, + + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + + regionColumnSize: data.regionColumnSize, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + + header: o.header, + items: o.items, + //交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + self._populate(); + self.table.populate(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.columnSize = this.getColumnSize(); + self._populate(); + self.table.populate(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + }, + + _getFreezeColLength: function () { + return this.options.isNeedFreeze === true ? this.options.freezeCols.length : 0; + }, + + _digest: function () { + var o = this.options; + var columnSize = o.columnSize.slice(); + var regionColumnSize = o.regionColumnSize.slice(); + var freezeCols = o.freezeCols.slice(); + var regionSize = o.regionColumnSize[0]; + var freezeColLength = this._getFreezeColLength(); + if (!regionSize || regionSize > o.width - 10 || regionSize < 10) { + regionSize = (freezeColLength > o.columnSize.length / 2 ? 2 / 3 : 1 / 3) * o.width; + } + if (freezeColLength === 0) { + regionSize = 0; + } + if (freezeCols.length >= columnSize.length) { + freezeCols = []; + } + if (!BI.isNumber(columnSize[0])) { + columnSize = o.minColumnSize; + } + var summaryFreezeColumnSize = 0, summaryColumnSize = 0; + BI.each(columnSize, function (i, size) { + if (i < freezeColLength) { + summaryFreezeColumnSize += size; + } + summaryColumnSize += size; + }); + if (freezeColLength > 0) { + columnSize[freezeColLength - 1] = BI.clamp(regionSize - (summaryFreezeColumnSize - columnSize[freezeColLength - 1]), + o.minColumnSize[freezeColLength - 1] || 10, o.maxColumnSize[freezeColLength - 1] || Number.MAX_VALUE); + } + if (columnSize.length > 0) { + columnSize[columnSize.length - 1] = BI.clamp(o.width - BI.GridTableScrollbar.SIZE - regionSize - (summaryColumnSize - summaryFreezeColumnSize - columnSize[columnSize.length - 1]), + o.minColumnSize[columnSize.length - 1] || 10, o.maxColumnSize[columnSize.length - 1] || Number.MAX_VALUE); + } + regionColumnSize[0] = regionSize; + + return { + freezeCols: freezeCols, + columnSize: columnSize, + regionColumnSize: regionColumnSize + } + }, + + _populate: function () { + var o = this.options; + var data = this._digest(); + o.regionColumnSize = data.regionColumnSize; + o.columnSize = data.columnSize; + this.table.setColumnSize(data.columnSize); + this.table.setRegionColumnSize(data.regionColumnSize); + this.table.attr("freezeCols", data.freezeCols); + }, + + setWidth: function (width) { + BI.AdaptiveTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(width); + }, + + setHeight: function (height) { + BI.AdaptiveTable.superclass.setHeight.apply(this, arguments); + this.table.setHeight(height); + }, + + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + setRegionColumnSize: function (regionColumnSize) { + this.options.regionColumnSize = regionColumnSize; + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + getLeftHorizontalScroll: function () { + return this.table.getLeftHorizontalScroll(); + }, + + getRightHorizontalScroll: function () { + return this.table.getRightHorizontalScroll(); + }, + + attr: function (key, value) { + var v = BI.AdaptiveTable.superclass.attr.apply(this, arguments); + if (key === "freezeCols") { + return v; + } + return this.table.attr.apply(this.table, arguments); + }, + + restore: function () { + this.table.restore(); + }, + + populate: function (items) { + var self = this, o = this.options; + this._populate(); + this.table.populate.apply(this.table, arguments); + }, + + destroy: function () { + this.table.destroy(); + BI.AdaptiveTable.superclass.destroy.apply(this, arguments); + } +}); +$.shortcut('bi.adaptive_table', BI.AdaptiveTable);/** * * 层级树状结构的表格 * @@ -5789,11 +6809,11 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.DynamicSummaryLayerTreeTable.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-dynamic-summary-layer-tree-table", - logic: { //冻结的页面布局逻辑 - dynamic: false - }, - isNeedResize: false,//是否需要调整列宽 + el: { + type: "bi.resizable_table" + }, + isNeedResize: true,//是否需要调整列宽 isResizeAdapt: true,//是否需要在调整列宽或区域宽度的时候它们自适应变化 isNeedFreeze: false,//是否需要冻结单元格 @@ -5801,16 +6821,18 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { isNeedMerge: true,//是否需要合并单元格 mergeCols: [], - mergeRule: function (row1, row2) { //合并规则, 默认相等时合并 - return BI.isEqual(row1, row2); - }, + mergeRule: BI.emptyFn, columnSize: [], headerRowSize: 25, footerRowSize: 25, rowSize: 25, - regionColumnSize: false, + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, header: [], footer: false, @@ -5834,30 +6856,34 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { _createHeader: function (vDeep) { var self = this, o = this.options; var header = o.header || [], crossHeader = o.crossHeader || []; - var items = BI.DynamicSummaryTreeTable.formatCrossItems(o.crossItems, vDeep); + var items = BI.TableTree.formatCrossItems(o.crossItems, vDeep, o.headerCellStyleGetter); var result = []; BI.each(items, function (row, node) { var c = [crossHeader[row]]; result.push(c.concat(node || [])); }); - var newHeader = this._formatColumns(header); - var deep = this._getHDeep(); - if (deep <= 0) { - newHeader.unshift({ - cls: "layer-tree-table-title", - text: BI.i18nText("BI-Row_Header") - }); - } else { - newHeader[0] = { - cls: "layer-tree-table-title", - text: BI.i18nText("BI-Row_Header") - }; + if (header && header.length > 0) { + var newHeader = this._formatColumns(header); + var deep = this._getHDeep(); + if (deep <= 0) { + newHeader.unshift({ + type: "bi.table_style_cell", + text: BI.i18nText("BI-Row_Header"), + styleGetter: o.headerCellStyleGetter + }); + } else { + newHeader[0] = { + type: "bi.table_style_cell", + text: BI.i18nText("BI-Row_Header"), + styleGetter: o.headerCellStyleGetter + }; + } + result.push(newHeader); } - result.push(newHeader); return result; }, - _formatItems: function (nodes, deep) { + _formatItems: function (nodes, header, deep) { var self = this, o = this.options; var result = []; @@ -5881,19 +6907,17 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { track(c, 0); }); if (BI.isArray(node.values)) { - var next = [{cls: "summary-cell last", text: BI.i18nText("BI-Summary_Values")}].concat(node.values); + var next = [{ + type: "bi.table_style_cell", + text: BI.i18nText("BI-Summary_Values"), + styleGetter: function () { + return o.summaryCellStyleGetter(true); + } + }].concat(node.values); result.push(next) } }); - return BI.DynamicSummaryTreeTable.formatSummaryItems(result, o.crossItems, deep); - }, - - _formatCols: function (cols, deep) { - deep = deep || this._getHDeep(); - cols = this._formatColumns(cols); - return BI.map(cols, function (i, c) { - return c - (deep - 1); - }) + return BI.DynamicSummaryTreeTable.formatSummaryItems(result, header, o.crossItems, 1); }, _formatColumns: function (columns, deep) { @@ -5904,97 +6928,124 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { return columns; }, - _init: function () { - BI.DynamicSummaryLayerTreeTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; - var deep = this._getHDeep(); - var vDeep = this._getVDeep(); - var header = this._createHeader(vDeep); - var items = this._formatItems(o.items, deep); - this.table = BI.createWidget({ - type: "bi.table_view", - element: this, - logic: o.logic, - isNeedResize: o.isNeedResize, - isResizeAdapt: o.isResizeAdapt, - isNeedFreeze: o.isNeedFreeze, - freezeCols: this._formatCols(o.freezeCols, deep), - isNeedMerge: o.isNeedMerge, - mergeCols: [], - mergeRule: o.mergeRule, - columnSize: this._formatColumns(o.columnSize, deep), + _formatFreezeCols: function () { + if (this.options.freezeCols.length > 0) { + return [0]; + } + return []; + }, + + _formatColumnSize: function (columnSize, deep) { + if (columnSize.length <= 0) { + return []; + } + var result = [0]; + deep = deep || this._getHDeep(); + BI.each(columnSize, function (i, size) { + if (i < deep) { + result[0] += size; + return; + } + result.push(size); + }); + return result; + }, + + _recomputeColumnSize: function () { + var o = this.options; + o.regionColumnSize = this.table.getRegionColumnSize(); + var columnSize = this.table.getColumnSize(); + if (o.freezeCols.length > 1) { + for (var i = 0; i < o.freezeCols.length - 1; i++) { + columnSize.splice(1, 0, 0); + } + } + o.columnSize = columnSize; + }, + + _digest: function () { + var o = this.options; + var deep = this._getHDeep(); + var vDeep = this._getVDeep(); + var header = this._createHeader(vDeep); + var data = this._formatItems(o.items, header, deep); + // var columnSize = o.columnSize.slice(); + // var minColumnSize = o.minColumnSize.slice(); + // var maxColumnSize = o.maxColumnSize.slice(); + // BI.removeAt(columnSize, data.deletedCols); + // BI.removeAt(minColumnSize, data.deletedCols); + // BI.removeAt(maxColumnSize, data.deletedCols); + return { + header: data.header, + items: data.items, + columnSize: this._formatColumnSize(o.columnSize, deep), + minColumnSize: this._formatColumns(o.minColumnSize, deep), + maxColumnSize: this._formatColumns(o.maxColumnSize, deep), + freezeCols: this._formatFreezeCols() + } + }, + + _init: function () { + BI.DynamicSummaryLayerTreeTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + var data = this._digest(); + this.table = BI.createWidget(o.el, { + type: "bi.resizable_table", + element: this, + width: o.width, + height: o.height, + isNeedResize: o.isNeedResize, + isResizeAdapt: o.isResizeAdapt, + isNeedFreeze: o.isNeedFreeze, + freezeCols: data.freezeCols, + isNeedMerge: o.isNeedMerge, + mergeCols: [], + mergeRule: o.mergeRule, + columnSize: data.columnSize, + minColumnSize: data.minColumnSize, + maxColumnSize: data.maxColumnSize, headerRowSize: o.headerRowSize, - footerRowSize: o.footerRowSize, rowSize: o.rowSize, regionColumnSize: o.regionColumnSize, - header: header, - footer: this._formatColumns(o.footer, deep), - items: items - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments); + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + header: data.header, + items: data.items }); this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); }); - this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments); - }); this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + self._recomputeColumnSize(); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); }); - this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments); - }); this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + self._recomputeColumnSize(); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); }); }, - resize: function () { - this.table.resize(); - }, - - setColumnSize: function (columnSize) { - columnSize = this._formatColumns(columnSize); - this.table.setColumnSize(columnSize); + setWidth: function (width) { + BI.DynamicSummaryLayerTreeTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(width); }, - getColumnSize: function () { - var columnSize = this.table.getColumnSize(); - var deep = this._getHDeep(); - var pre = []; - if (deep > 0) { - pre = BI.makeArray(deep - 1, 0); - } - return pre.concat(columnSize); + setHeight: function (height) { + BI.DynamicSummaryLayerTreeTable.superclass.setHeight.apply(this, arguments); + this.table.setHeight(height); }, - getCalculateColumnSize: function () { - var columnSize = this.table.getCalculateColumnSize(); - var deep = this._getHDeep(); - var pre = []; - if (deep > 0) { - pre = BI.makeArray(deep - 1, ""); - } - return pre.concat(columnSize); + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; }, - setHeaderColumnSize: function (columnSize) { - columnSize = this._formatColumns(columnSize); - this.table.setHeaderColumnSize(columnSize); + getColumnSize: function () { + return this.options.columnSize; }, setRegionColumnSize: function (columnSize) { + this.options.regionColumnSize = columnSize; this.table.setRegionColumnSize(columnSize); }, @@ -6002,30 +7053,6 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { return this.table.getRegionColumnSize(); }, - getCalculateRegionColumnSize: function () { - return this.table.getCalculateRegionColumnSize(); - }, - - getCalculateRegionRowSize: function () { - return this.table.getCalculateRegionRowSize(); - }, - - getClientRegionColumnSize: function () { - return this.table.getClientRegionColumnSize(); - }, - - getScrollRegionColumnSize: function () { - return this.table.getScrollRegionColumnSize(); - }, - - getScrollRegionRowSize: function () { - return this.table.getScrollRegionRowSize(); - }, - - hasVerticalScroll: function () { - return this.table.hasVerticalScroll(); - }, - setVerticalScroll: function (scrollTop) { this.table.setVerticalScroll(scrollTop); }, @@ -6050,10 +7077,6 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { return this.table.getRightHorizontalScroll(); }, - getColumns: function () { - return this.table.getColumns(); - }, - attr: function (key, value) { var self = this; if (BI.isObject(key)) { @@ -6065,22 +7088,24 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { BI.DynamicSummaryLayerTreeTable.superclass.attr.apply(this, arguments); switch (key) { case "columnSize": - case "footer": - value = this._formatColumns(value); - break; + case "minColumnSize": + case "maxColumnSize": case "freezeCols": - value = value.length > 0 ? [0] : []; - break; case "mergeCols": - value = value.length > 0 ? [0] : []; - break; + return; } this.table.attr.apply(this.table, [key, value]); }, + restore: function () { + this.table.restore(); + }, + populate: function (items, header, crossItems, crossHeader) { var o = this.options; - o.items = items || []; + if (items) { + o.items = items; + } if (header) { o.header = header; } @@ -6090,11 +7115,12 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { if (crossHeader) { o.crossHeader = crossHeader; } - var deep = this._getHDeep(); - var vDeep = this._getVDeep(); - var header = this._createHeader(vDeep); - items = this._formatItems(o.items, deep); - this.table.populate(items, header); + var data = this._digest(); + this.table.setColumnSize(data.columnSize); + this.table.attr("minColumnSize", data.minColumnSize); + this.table.attr("maxColumnSize", data.maxColumnSize); + this.table.attr("freezeCols", data.freezeCols); + this.table.populate(data.items, data.header); }, destroy: function () { @@ -6115,11 +7141,11 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.DynamicSummaryTreeTable.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-dynamic-summary-tree-table", - logic: { //冻结的页面布局逻辑 - dynamic: false + el: { + type: "bi.resizable_table" }, - isNeedResize: false,//是否需要调整列宽 + isNeedResize: true,//是否需要调整列宽 isResizeAdapt: true,//是否需要在调整列宽或区域宽度的时候它们自适应变化 isNeedFreeze: false,//是否需要冻结单元格 @@ -6127,16 +7153,18 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { isNeedMerge: true,//是否需要合并单元格 mergeCols: [], - mergeRule: function (row1, row2) { //合并规则, 默认相等时合并 - return BI.isEqual(row1, row2); - }, + mergeRule: BI.emptyFn, columnSize: [], headerRowSize: 25, footerRowSize: 25, rowSize: 25, - regionColumnSize: false, + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, header: [], footer: false, @@ -6148,22 +7176,6 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { }) }, - _createHeader: function (deep, vDeep) { - var self = this, o = this.options; - var header = o.header || [], crossHeader = o.crossHeader || []; - var items = BI.DynamicSummaryTreeTable.formatCrossItems(o.crossItems, vDeep); - var result = []; - BI.each(items, function (row, node) { - var c = []; - for (var i = 0; i < deep; i++) { - c.push(crossHeader[row]); - } - result.push(c.concat(node || [])); - }); - result.push(header); - return result; - }, - _getVDeep: function () { return this.options.crossHeader.length;//纵向深度 }, @@ -6176,15 +7188,12 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { _init: function () { BI.DynamicSummaryTreeTable.superclass._init.apply(this, arguments); var self = this, o = this.options; - var deep = this._getHDeep(); - var vDeep = this._getVDeep(); - var header = this._createHeader(deep, vDeep); - var items = BI.DynamicSummaryTreeTable.formatItems(o.items, deep); - items = BI.DynamicSummaryTreeTable.formatSummaryItems(items, o.crossItems, deep); - this.table = BI.createWidget({ - type: "bi.table_view", + var data = this._digest(); + this.table = BI.createWidget(o.el, { + type: "bi.resizable_table", element: this, - logic: o.logic, + width: o.width, + height: o.height, isNeedResize: o.isNeedResize, isResizeAdapt: o.isResizeAdapt, @@ -6197,65 +7206,74 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { columnSize: o.columnSize, headerRowSize: o.headerRowSize, - footerRowSize: o.footerRowSize, rowSize: o.rowSize, regionColumnSize: o.regionColumnSize, - header: header, - footer: o.footer, - items: items - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments); + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + + header: data.header, + items: data.items }); this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); }); - this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments); - }); this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); }); - this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments); - }); this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); }); }, - resize: function () { - this.table.resize(); + _digest: function () { + var o = this.options; + var deep = this._getHDeep(); + var vDeep = this._getVDeep(); + var header = BI.TableTree.formatHeader(o.header, o.crossHeader, o.crossItems, deep, vDeep, o.headerCellStyleGetter); + var items = BI.DynamicSummaryTreeTable.formatHorizontalItems(o.items, deep, false, o.summaryCellStyleGetter); + var data = BI.DynamicSummaryTreeTable.formatSummaryItems(items, header, o.crossItems, deep); + var columnSize = o.columnSize.slice(); + var minColumnSize = o.minColumnSize.slice(); + var maxColumnSize = o.maxColumnSize.slice(); + BI.removeAt(columnSize, data.deletedCols); + BI.removeAt(minColumnSize, data.deletedCols); + BI.removeAt(maxColumnSize, data.deletedCols); + return { + header: data.header, + items: data.items, + columnSize: columnSize, + minColumnSize: minColumnSize, + maxColumnSize: maxColumnSize + }; }, - setColumnSize: function (columnSize) { - this.table.setColumnSize(columnSize); + setWidth: function (width) { + BI.DynamicSummaryTreeTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(width); }, - getColumnSize: function () { - return this.table.getColumnSize(); + setHeight: function (height) { + BI.DynamicSummaryTreeTable.superclass.setHeight.apply(this, arguments); + this.table.setHeight(height); }, - getCalculateColumnSize: function () { - return this.table.getCalculateColumnSize(); + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; }, - setHeaderColumnSize: function (columnSize) { - this.table.setHeaderColumnSize(columnSize); + getColumnSize: function () { + return this.table.getColumnSize(); }, setRegionColumnSize: function (columnSize) { + this.options.regionColumnSize = columnSize; this.table.setRegionColumnSize(columnSize); }, @@ -6263,30 +7281,6 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { return this.table.getRegionColumnSize(); }, - getCalculateRegionColumnSize: function () { - return this.table.getCalculateRegionColumnSize(); - }, - - getCalculateRegionRowSize: function () { - return this.table.getCalculateRegionRowSize(); - }, - - getClientRegionColumnSize: function () { - return this.table.getClientRegionColumnSize(); - }, - - getScrollRegionColumnSize: function () { - return this.table.getScrollRegionColumnSize(); - }, - - getScrollRegionRowSize: function () { - return this.table.getScrollRegionRowSize(); - }, - - hasVerticalScroll: function () { - return this.table.hasVerticalScroll(); - }, - setVerticalScroll: function (scrollTop) { this.table.setVerticalScroll(scrollTop); }, @@ -6311,18 +7305,25 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { return this.table.getRightHorizontalScroll(); }, - getColumns: function () { - return this.table.getColumns(); - }, - - attr: function () { + attr: function (key) { BI.DynamicSummaryTreeTable.superclass.attr.apply(this, arguments); + switch (key) { + case "minColumnSize": + case "maxColumnSize": + return; + } this.table.attr.apply(this.table, arguments); }, + restore: function () { + this.table.restore(); + }, + populate: function (items, header, crossItems, crossHeader) { var o = this.options; - o.items = items || []; + if (items) { + o.items = items; + } if (header) { o.header = header; } @@ -6332,12 +7333,11 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { if (crossHeader) { o.crossHeader = crossHeader; } - var deep = this._getHDeep(); - var vDeep = this._getVDeep(); - var header = this._createHeader(deep, vDeep); - items = BI.DynamicSummaryTreeTable.formatItems(o.items, deep); - items = BI.DynamicSummaryTreeTable.formatSummaryItems(items, o.crossItems, deep); - this.table.populate(items, header); + var data = this._digest(); + this.table.setColumnSize(data.columnSize); + this.table.attr("minColumnSize", data.minColumnSize); + this.table.attr("maxColumnSize", data.maxColumnSize); + this.table.populate(data.items, data.header); }, destroy: function () { @@ -6347,8 +7347,8 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { }); BI.extend(BI.DynamicSummaryTreeTable, { - formatItems: function (nodes, deep, isCross) { - var self = this; + + formatHorizontalItems: function (nodes, deep, isCross, styleGetter) { var result = []; function track(store, node) { @@ -6357,7 +7357,7 @@ BI.extend(BI.DynamicSummaryTreeTable, { BI.each(node.children, function (index, child) { var next; if (store != -1) { - next = BI.clone(store); + next = store.slice(); next.push(node); } else { next = []; @@ -6365,16 +7365,21 @@ BI.extend(BI.DynamicSummaryTreeTable, { track(next, child); }); if (store != -1) { - next = BI.clone(store); + next = store.slice(); next.push(node); } else { next = []; } if ((store == -1 || node.children.length > 1) && BI.isNotEmptyArray(node.values)) { - var cls = store === -1 ? " last" : ""; - var id = BI.UUID(); + var summary = { + text: BI.i18nText("BI-Summary_Values"), + type: "bi.table_style_cell", + styleGetter: function () { + return styleGetter(store === -1) + } + }; for (var i = next.length; i < deep; i++) { - next.push({text: BI.i18nText("BI-Summary_Values"), tag: id, cls: "summary-cell" + cls}); + next.push(summary); } if (!isCross) { next = next.concat(node.values); @@ -6392,7 +7397,7 @@ BI.extend(BI.DynamicSummaryTreeTable, { return; } if (store != -1) { - next = BI.clone(store); + next = store.slice(); for (var i = next.length; i < deep; i++) { next.push(node); } @@ -6420,19 +7425,14 @@ BI.extend(BI.DynamicSummaryTreeTable, { //填充空位 BI.each(result, function (i, line) { var last = BI.last(line); - for (var i = line.length; i < deep; i++) { + for (var j = line.length; j < deep; j++) { line.push(last); } }); return result; }, - formatCrossItems: function (nodes, deep) { - var items = BI.DynamicSummaryTreeTable.formatItems(nodes, deep, true); - return BI.unzip(items); - }, - - formatSummaryItems: function (items, crossItems, deep) { + formatSummaryItems: function (items, header, crossItems, deep) { //求纵向需要去除的列 var cols = []; var leaf = 0; @@ -6443,14 +7443,20 @@ BI.extend(BI.DynamicSummaryTreeTable, { track(child); }); if (BI.isNotEmptyArray(node.values)) { - leaf++; if (node.children.length === 1) { - cols.push(leaf - 1 + deep); + for (var i = 0; i < node.values.length; i++) { + cols.push(leaf + i + deep); + } } + leaf += node.values.length; } return; } - leaf++; + if (node.values && node.values.length > 1) { + leaf += node.values.length; + } else { + leaf++; + } } BI.each(crossItems, function (i, node) { @@ -6458,46 +7464,18 @@ BI.extend(BI.DynamicSummaryTreeTable, { }); if (cols.length > 0) { + BI.each(header, function (i, node) { + BI.removeAt(node, cols); + }); BI.each(items, function (i, node) { BI.removeAt(node, cols); - }) + }); } - return items; + return {items: items, header: header, deletedCols: cols}; } }); $.shortcut("bi.dynamic_summary_tree_table", BI.DynamicSummaryTreeTable);/** - * Created by GUY on 2016/5/7. - * @class BI.LayerTreeTableCell - * @extends BI.Single - */ -BI.LayerTreeTableCell = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.LayerTreeTableCell.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-layer-tree-table-cell", - layer: 0, - text: "" - }) - }, - - _init: function () { - BI.LayerTreeTableCell.superclass._init.apply(this, arguments); - var o = this.options; - BI.createWidget({ - type: "bi.label", - element: this, - textAlign: "left", - whiteSpace: "nowrap", - height: o.height, - text: o.text, - value: o.value, - lgap: 5 + 30 * o.layer, - rgap: 5 - }) - } -}); - -$.shortcut("bi.layer_tree_table_cell", BI.LayerTreeTableCell);/** * * 层级树状结构的表格 * @@ -6509,8 +7487,8 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.LayerTreeTable.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-layer-tree-table", - logic: { //冻结的页面布局逻辑 - dynamic: false + el: { + type: "bi.resizable_table" }, isNeedResize: false,//是否需要调整列宽 @@ -6521,19 +7499,22 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { isNeedMerge: true,//是否需要合并单元格 mergeCols: [], - mergeRule: function (row1, row2) { //合并规则, 默认相等时合并 - return BI.isEqual(row1, row2); - }, + mergeRule: BI.emptyFn, columnSize: [], + minColumnSize: [], + maxColumnSize: [], + headerRowSize: 25, - footerRowSize: 25, rowSize: 25, - regionColumnSize: false, + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, header: [], - footer: false, items: [], //交叉表头 @@ -6554,31 +7535,35 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { _createHeader: function (vDeep) { var self = this, o = this.options; var header = o.header || [], crossHeader = o.crossHeader || []; - var items = BI.TableTree.formatCrossItems(o.crossItems, vDeep); + var items = BI.TableTree.formatCrossItems(o.crossItems, vDeep, o.headerCellStyleGetter); var result = []; BI.each(items, function (row, node) { var c = [crossHeader[row]]; result.push(c.concat(node || [])); }); - var newHeader = this._formatColumns(header); - var deep = this._getHDeep(); - if (deep <= 0) { - newHeader.unshift({ - cls: "layer-tree-table-title", - text: BI.i18nText("BI-Row_Header") - }); - } else { - newHeader[0] = { - cls: "layer-tree-table-title", - text: BI.i18nText("BI-Row_Header") - }; + if (header && header.length > 0) { + var newHeader = this._formatColumns(header); + var deep = this._getHDeep(); + if (deep <= 0) { + newHeader.unshift({ + type: "bi.table_style_cell", + text: BI.i18nText("BI-Row_Header"), + styleGetter: o.headerCellStyleGetter + }); + } else { + newHeader[0] = { + type: "bi.table_style_cell", + text: BI.i18nText("BI-Row_Header"), + styleGetter: o.headerCellStyleGetter + }; + } + result.push(newHeader); } - result.push(newHeader); return result; }, _formatItems: function (nodes) { - var self = this; + var self = this, o = this.options; var result = []; function track(node, layer) { @@ -6596,125 +7581,399 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { } } - BI.each(nodes, function (i, node) { - BI.each(node.children, function (j, c) { - track(c, 0); - }); - if (BI.isArray(node.values)) { - var next = [{cls: "summary-cell last", text: BI.i18nText("BI-Summary_Values")}].concat(node.values); - result.push(next) - } - }); - return result; - }, + BI.each(nodes, function (i, node) { + BI.each(node.children, function (j, c) { + track(c, 0); + }); + if (BI.isArray(node.values)) { + var next = [{ + type: "bi.table_style_cell", text: BI.i18nText("BI-Summary_Values"), styleGetter: function () { + return o.summaryCellStyleGetter(true); + } + }].concat(node.values); + result.push(next) + } + }); + return result; + }, + + _formatColumns: function (columns, deep) { + if (BI.isNotEmptyArray(columns)) { + deep = deep || this._getHDeep(); + return columns.slice(Math.max(0, deep - 1)); + } + return columns; + }, + + _formatFreezeCols: function () { + if (this.options.freezeCols.length > 0) { + return [0]; + } + return []; + }, + + _formatColumnSize: function (columnSize, deep) { + if (columnSize.length <= 0) { + return []; + } + var result = [0]; + deep = deep || this._getHDeep(); + BI.each(columnSize, function (i, size) { + if (i < deep) { + result[0] += size; + return; + } + result.push(size); + }); + return result; + }, + + _digest: function () { + var o = this.options; + var deep = this._getHDeep(); + var vDeep = this._getVDeep(); + return { + header: this._createHeader(vDeep), + items: this._formatItems(o.items), + columnSize: this._formatColumnSize(o.columnSize, deep), + minColumnSize: this._formatColumns(o.minColumnSize, deep), + maxColumnSize: this._formatColumns(o.maxColumnSize, deep), + freezeCols: this._formatFreezeCols() + } + }, + + _init: function () { + BI.LayerTreeTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var data = this._digest(); + this.table = BI.createWidget(o.el, { + type: "bi.resizable_table", + element: this, + width: o.width, + height: o.height, + isNeedResize: o.isNeedResize, + isResizeAdapt: o.isResizeAdapt, + isNeedFreeze: o.isNeedFreeze, + freezeCols: data.freezeCols, + isNeedMerge: o.isNeedMerge, + mergeCols: [], + mergeRule: o.mergeRule, + columnSize: data.columnSize, + minColumnSize: data.minColumnSize, + maxColumnSize: data.maxColumnSize, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + regionColumnSize: o.regionColumnSize, + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + header: data.header, + items: data.items + }); + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + }, + + setWidth: function (width) { + BI.LayerTreeTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(width); + }, + + setHeight: function (height) { + BI.LayerTreeTable.superclass.setHeight.apply(this, arguments); + this.table.setHeight(height); + }, + + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + }, + + getColumnSize: function () { + var columnSize = this.table.getColumnSize(); + var deep = this._getHDeep(); + var pre = []; + if (deep > 0) { + pre = BI.makeArray(deep, columnSize[0] / deep); + } + return pre.concat(columnSize.slice(1)); + }, + + setRegionColumnSize: function (columnSize) { + this.options.regionColumnSize = columnSize; + this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + getLeftHorizontalScroll: function () { + return this.table.getLeftHorizontalScroll(); + }, + + getRightHorizontalScroll: function () { + return this.table.getRightHorizontalScroll(); + }, + + attr: function (key, value) { + var self = this; + if (BI.isObject(key)) { + BI.each(key, function (k, v) { + self.attr(k, v); + }); + return; + } + BI.LayerTreeTable.superclass.attr.apply(this, arguments); + switch (key) { + case "columnSize": + case "minColumnSize": + case "maxColumnSize": + case "freezeCols": + case "mergeCols": + return; + } + this.table.attr.apply(this.table, [key, value]); + }, + + restore: function () { + this.table.restore(); + }, + + populate: function (items, header, crossItems, crossHeader) { + var o = this.options; + o.items = items || []; + if (header) { + o.header = header; + } + if (crossItems) { + o.crossItems = crossItems; + } + if (crossHeader) { + o.crossHeader = crossHeader; + } + var data = this._digest(); + this.table.setColumnSize(data.columnSize); + this.table.attr("freezeCols", data.freezeCols); + this.table.attr("minColumnSize", data.minColumnSize); + this.table.attr("maxColumnSize", data.maxColumnSize); + this.table.populate(data.items, data.header); + }, + + destroy: function () { + this.table.destroy(); + BI.LayerTreeTable.superclass.destroy.apply(this, arguments); + } +}); + +$.shortcut("bi.layer_tree_table", BI.LayerTreeTable);/** + * + * Created by GUY on 2016/5/26. + * @class BI.TableStyleCell + * @extends BI.Single + */ +BI.TableStyleCell = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.TableStyleCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-table-style-cell", + styleGetter: BI.emptyFn + }); + }, + + _init: function () { + BI.TableStyleCell.superclass._init.apply(this, arguments); + var o = this.options; + this.text = BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + forceCenter: true, + hgap: 5, + text: o.text + }); + this._digestStyle(); + }, + + _digestStyle: function () { + var o = this.options; + var style = o.styleGetter(); + if (style) { + this.text.element.css(style); + } + }, + + setText: function (text) { + this.text.setText(text); + }, + + populate: function () { + this._digestStyle(); + } +}); +$.shortcut('bi.table_style_cell', BI.TableStyleCell);/** + * + * 树状结构的表格 + * + * Created by GUY on 2015/9/22. + * @class BI.TableTree + * @extends BI.Widget + */ +BI.TableTree = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.TableTree.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-table-tree", + el: { + type: "bi.resizable_table" + }, + isNeedResize: true,//是否需要调整列宽 + isResizeAdapt: true,//是否需要在调整列宽或区域宽度的时候它们自适应变化 + + freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为tree时生效 - _formatCols: function (cols, deep) { - deep = deep || this._getHDeep(); - cols = this._formatColumns(cols); - return BI.map(cols, function (i, c) { - return c - (deep - 1); + isNeedMerge: true,//是否需要合并单元格 + mergeCols: [], + mergeRule: BI.emptyFn, + + columnSize: [], + minColumnSize: [], + maxColumnSize: [], + headerRowSize: 25, + rowSize: 25, + + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, + + header: [], + items: [], + + //交叉表头 + crossHeader: [], + crossItems: [] }) }, - _formatColumns: function (columns, deep) { - if (BI.isNotEmptyArray(columns)) { - deep = deep || this._getHDeep(); - return columns.slice(Math.max(0, deep - 1)); - } - return columns; + _getVDeep: function () { + return this.options.crossHeader.length;//纵向深度 + }, + + _getHDeep: function () { + var o = this.options; + return Math.max(o.mergeCols.length, o.freezeCols.length, BI.TableTree.maxDeep(o.items) - 1); }, _init: function () { - BI.LayerTreeTable.superclass._init.apply(this, arguments); + BI.TableTree.superclass._init.apply(this, arguments); var self = this, o = this.options; - var deep = this._getHDeep(); - var vDeep = this._getVDeep(); - var header = this._createHeader(vDeep); - var items = this._formatItems(o.items); - this.table = BI.createWidget({ - type: "bi.table_view", + var data = this._digest(); + this.table = BI.createWidget(o.el, { + type: "bi.resizable_table", element: this, - logic: o.logic, + width: o.width, + height: o.height, isNeedResize: o.isNeedResize, isResizeAdapt: o.isResizeAdapt, + isNeedFreeze: o.isNeedFreeze, - freezeCols: this._formatCols(o.freezeCols, deep), + freezeCols: o.freezeCols, isNeedMerge: o.isNeedMerge, - mergeCols: [], + mergeCols: o.mergeCols, mergeRule: o.mergeRule, - columnSize: this._formatColumns(o.columnSize, deep), + + columnSize: o.columnSize, + minColumnSize: o.minColumnSize, + maxColumnSize: o.maxColumnSize, + headerRowSize: o.headerRowSize, - footerRowSize: o.footerRowSize, rowSize: o.rowSize, + regionColumnSize: o.regionColumnSize, - header: header, - footer: this._formatColumns(o.footer, deep), - items: items - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments); + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + + header: data.header, + items: data.items }); this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); }); - this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments); - }); this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); }); - this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments); - }); this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); }); }, - resize: function () { - this.table.resize(); + _digest: function () { + var self = this, o = this.options; + var deep = this._getHDeep(); + var vDeep = this._getVDeep(); + var header = BI.TableTree.formatHeader(o.header, o.crossHeader, o.crossItems, deep, vDeep, o.headerCellStyleGetter); + var items = BI.TableTree.formatItems(o.items, deep, false, o.summaryCellStyleGetter); + return { + header: header, + items: items + } }, - setColumnSize: function (columnSize) { - columnSize = this._formatColumns(columnSize); - this.table.setColumnSize(columnSize); + setWidth: function (width) { + BI.TableTree.superclass.setWidth.apply(this, arguments); + this.table.setWidth(width); }, - getColumnSize: function () { - var columnSize = this.table.getColumnSize(); - var deep = this._getHDeep(); - var pre = []; - if (deep > 0) { - pre = BI.makeArray(deep - 1, 0); - } - return pre.concat(columnSize); + setHeight: function (height) { + BI.TableTree.superclass.setHeight.apply(this, arguments); + this.table.setHeight(height); }, - getCalculateColumnSize: function () { - var columnSize = this.table.getCalculateColumnSize(); - var deep = this._getHDeep(); - var pre = []; - if (deep > 0) { - pre = BI.makeArray(deep - 1, ""); - } - return pre.concat(columnSize); + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setColumnSize(columnSize); }, - setHeaderColumnSize: function (columnSize) { - columnSize = this._formatColumns(columnSize); - this.table.setHeaderColumnSize(columnSize); + getColumnSize: function () { + return this.table.getColumnSize(); }, setRegionColumnSize: function (columnSize) { + this.options.regionColumnSize = columnSize; this.table.setRegionColumnSize(columnSize); }, @@ -6722,30 +7981,6 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { return this.table.getRegionColumnSize(); }, - getCalculateRegionColumnSize: function () { - return this.table.getCalculateRegionColumnSize(); - }, - - getCalculateRegionRowSize: function () { - return this.table.getCalculateRegionRowSize(); - }, - - getClientRegionColumnSize: function () { - return this.table.getClientRegionColumnSize(); - }, - - getScrollRegionColumnSize: function () { - return this.table.getScrollRegionColumnSize(); - }, - - getScrollRegionRowSize: function () { - return this.table.getScrollRegionRowSize(); - }, - - hasVerticalScroll: function () { - return this.table.hasVerticalScroll(); - }, - setVerticalScroll: function (scrollTop) { this.table.setVerticalScroll(scrollTop); }, @@ -6770,37 +8005,20 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { return this.table.getRightHorizontalScroll(); }, - getColumns: function () { - return this.table.getColumns(); + attr: function () { + BI.TableTree.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); }, - attr: function (key, value) { - var self = this; - if (BI.isObject(key)) { - BI.each(key, function (k, v) { - self.attr(k, v); - }); - return; - } - BI.LayerTreeTable.superclass.attr.apply(this, arguments); - switch (key) { - case "columnSize": - case "footer": - value = this._formatColumns(value); - break; - case "freezeCols": - value = value.length > 0 ? [0] : []; - break; - case "mergeCols": - value = value.length > 0 ? [0] : []; - break; - } - this.table.attr.apply(this.table, [key, value]); + restore: function () { + this.table.restore(); }, populate: function (items, header, crossItems, crossHeader) { var o = this.options; - o.items = items || []; + if (items) { + o.items = items || []; + } if (header) { o.header = header; } @@ -6810,110 +8028,146 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { if (crossHeader) { o.crossHeader = crossHeader; } - var vDeep = this._getVDeep(); - var header = this._createHeader(vDeep); - items = this._formatItems(o.items); - this.table.populate(items, header); + var data = this._digest(); + this.table.populate(data.items, data.header); }, destroy: function () { this.table.destroy(); - BI.LayerTreeTable.superclass.destroy.apply(this, arguments); + BI.TableTree.superclass.destroy.apply(this, arguments); } }); -$.shortcut("bi.layer_tree_table", BI.LayerTreeTable);/** - * 分页table - * - * Created by GUY on 2015/9/8. - * @class BI.Tabler - * @extends BI.Widget - */ -BI.Tabler = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.Tabler.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-tabler", - - pager: {}, - - layouts: [{ - type: "bi.float_center_adapt" - }], - - tabler: { - isNeedFreeze: false,//是否需要冻结单元格 - freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为tree时生效 - - isNeedMerge: true,//是否需要合并单元格 +BI.extend(BI.TableTree, { + formatHeader: function (header, crossHeader, crossItems, hDeep, vDeep, styleGetter) { + var items = BI.TableTree.formatCrossItems(crossItems, vDeep, styleGetter); + var result = []; + for (var i = 0; i < vDeep; i++) { + var c = []; + for (var j = 0; j < hDeep; j++) { + c.push(crossHeader[i]); + } + result.push(c.concat(items[i] || [])); + } + if (header && header.length > 0) { + result.push(header); + } + return result; + }, - mergeRule: function (row1, row2) { //合并规则, 默认相等时合并 - return BI.isEqual(row1, row2); - }, + formatItems: function (nodes, deep, isCross, styleGetter) { + var self = this; + var result = []; - columnSize: [], - rowSize: 37, - header: [], - items: [], + function track(store, node) { + var next; + if (BI.isArray(node.children)) { + BI.each(node.children, function (index, child) { + var next; + if (store != -1) { + next = store.slice(); + next.push(node); + } else { + next = []; + } + track(next, child); + }); + if (store != -1) { + next = store.slice(); + next.push(node); + } else { + next = []; + } + if (/**(store == -1 || node.children.length > 1) &&**/ BI.isNotEmptyArray(node.values)) { + var summary = { + text: BI.i18nText("BI-Summary_Values"), + type: "bi.table_style_cell", + styleGetter: function () { + return styleGetter(store === -1) + } + }; + for (var i = next.length; i < deep; i++) { + next.push(summary); + } + if (!isCross) { + next = next.concat(node.values); + } + if (next.length > 0) { + if (!isCross) { + result.push(next); + } else { + for (var k = 0, l = node.values.length; k < l; k++) { + result.push(next); + } + } + } + } - //交叉表头 - crossHeader: [], - crossItems: [] + return; } - }) - }, - _init: function () { - BI.Tabler.superclass._init.apply(this, arguments); - var self = this, o = this.options; + if (store != -1) { + next = store.slice(); + for (var i = next.length; i < deep; i++) { + next.push(node); + } + } else { + next = []; + } + if (!isCross && BI.isArray(node.values)) { + next = next.concat(node.values); + } + if (isCross && BI.isArray(node.values)) { + for (var i = 0, len = node.values.length; i < len - 1; i++) { + if (next.length > 0) { + result.push(next); + } + } + } + if (next.length > 0) { + result.push(next); + } + } - this.pager = BI.createWidget(o.pager, { - type: "bi.pager" + BI.each(nodes, function (i, node) { + track(-1, node); }); - var creater = BI.createWidget({ - type: "bi.button_tree", - items: [{ - el: this.pager - }], - layouts: o.layouts - }) - this.pager.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - self.fireEvent(BI.Tabler.EVENT_CHANGE); + //填充空位 + BI.each(result, function (i, line) { + var last = BI.last(line); + for (var j = line.length; j < deep; j++) { + line.push(last); } }); - this.container = BI.createWidget({ - type: "bi.layout" - }) - BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - el: this.container - }, { - el: creater, - height: 40 - }] - }); - this.populate(); + return result; }, - getCurrentPage: function () { - return this.pager.getValue(); + formatCrossItems: function (nodes, deep, styleGetter) { + var items = BI.TableTree.formatItems(nodes, deep, true, styleGetter); + return BI.unzip(items); }, - populate: function (opt) { - var o = this.options; - this.container.empty(); + maxDeep: function (nodes) { + function track(deep, node) { + var d = deep; + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + d = Math.max(d, track(deep + 1, child)); + }); + } + return d; + } - BI.extend(o.tabler, opt); - this.table = BI.createWidget(this.options.tabler, { - type: "bi.table_tree", - element: this.container - }); + var deep = 1; + if (BI.isObject(nodes)) { + BI.each(nodes, function (i, node) { + deep = Math.max(deep, track(1, node)); + }); + } + return deep; } }); -BI.Tabler.EVENT_CHANGE = "EVENT_CHANGE"; -$.shortcut("bi.tabler", BI.Tabler);/** + +$.shortcut("bi.table_tree", BI.TableTree);/** * guy * 气泡提示 * @class BI.Bubble @@ -7101,29 +8355,55 @@ BI.Tooltip = BI.inherit(BI.Tip, { e.stopEvent(); return false; }; - this.element.bind({"click": fn, "mousedown": fn, "mouseup": fn, "mouseover": fn, "mouseenter": fn, "mouseleave": fn, "mousemove": fn}); - - this.text = BI.createWidget({ - type: "bi.label", - element: this, - textAlign: "left", - whiteSpace: "normal", - text: o.text, - textHeight: 20, - hgap: this._const.hgap - }); + this.element.bind({ + "click": fn, + "mousedown": fn, + "mouseup": fn, + "mouseover": fn, + "mouseenter": fn, + "mouseleave": fn, + "mousemove": fn + }); + + var texts = (o.text + "").split("\n"); + if (texts.length > 1) { + BI.createWidget({ + type: "bi.vertical", + element: this, + hgap: this._const.hgap, + items: BI.map(texts, function (i, text) { + return { + type: "bi.label", + textAlign: "left", + whiteSpace: "normal", + text: text, + textHeight: 16 + } + }) + }) + } else { + this.text = BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "normal", + text: o.text, + textHeight: 20, + hgap: this._const.hgap + }); + } }, - setWidth: function(width){ + setWidth: function (width) { this.element.width(width - 2 * this._const.hgap); }, setText: function (text) { - this.text.setText(text); + this.text && this.text.setText(text); }, setLevel: function (level) { - this.element.removeClass("tooltip-success").removeClass("tooltip-warning"); + this.element.removeClass("tooltip-success").removeClass("tooltip-warning"); this.element.addClass("tooltip-" + level); } }); @@ -7846,10 +9126,12 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { setValue: function (value) { this.text.setValue(value); + this.text.setTitle(value); }, setText: function (text) { this.text.setText(text); + this.text.setTitle(text); } }); $.shortcut("bi.text_trigger", BI.TextTrigger);/** @@ -7888,7 +9170,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { var result = []; var items = BI.Tree.transformToArrayFormat(this.options.items); BI.each(items, function (i, item) { - if (BI.deepContains(vals, item.value)) { + if (BI.deepContains(vals, item.value) && !result.contains(item.text || item.value)) { result.push(item.text || item.value); } }); @@ -7941,7 +9223,7 @@ BI.SmallSelectTextTrigger = BI.inherit(BI.Trigger, { var result = []; var items = BI.Tree.transformToArrayFormat(this.options.items); BI.each(items, function (i, item) { - if (BI.deepContains(vals, item.value)) { + if (BI.deepContains(vals, item.value) && !result.contains(item.text || item.value)) { result.push(item.text || item.value); } }); @@ -8043,7 +9325,7 @@ BI.ZeroClip = BI.inherit(BI.BasicButton, { FR.$defaultImport('/com/fr/bi/web/js/third/jquery.zclip.js', 'js'); BI.nextTick(function () { self.element.zclip({ - path: "resources/ZeroClipboard.swf", + path: FR.servletURL + "?op=resource&resource=/com/fr/bi/web/resources/ZeroClipboard.swf", copy: o.copy, beforeCopy: o.beforeCopy, afterCopy: o.afterCopy diff --git a/src/case/button/item.multiselect.js b/src/case/button/item.multiselect.js index b43a3a5ec..4b8a06b66 100644 --- a/src/case/button/item.multiselect.js +++ b/src/case/button/item.multiselect.js @@ -50,6 +50,11 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, { })))); }, + setEnable: function (v) { + BI.MultiSelectItem.superclass.setEnable.apply(this, arguments); + this.checkbox.setEnable(v); + }, + doRedMark: function(){ this.text.doRedMark.apply(this.text, arguments); }, @@ -68,5 +73,5 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, { this.checkbox.setSelected(v); } }); - +BI.MultiSelectItem.EVENT_CHANGE = "EVENT_CHANGE"; $.shortcut("bi.multi_select_item", BI.MultiSelectItem); \ No newline at end of file diff --git a/src/case/button/item.singleselect.js b/src/case/button/item.singleselect.js index cf817866e..f70ce7876 100644 --- a/src/case/button/item.singleselect.js +++ b/src/case/button/item.singleselect.js @@ -8,7 +8,8 @@ BI.SingleSelectItem = BI.inherit(BI.BasicButton, { return BI.extend(BI.SingleSelectItem.superclass._defaultConfig.apply(this, arguments), { extraCls: "bi-single-select-item bi-list-item-active", hgap: 10, - height: 25 + height: 25, + textAlign: "left", }) }, _init: function () { @@ -17,7 +18,7 @@ BI.SingleSelectItem = BI.inherit(BI.BasicButton, { this.text = BI.createWidget({ type: "bi.label", element: this, - textAlign: "left", + textAlign: o.textAlign, whiteSpace: "nowrap", textHeight: o.height, height: o.height, diff --git a/src/case/button/node/node.multilayer.icon.arrow.js b/src/case/button/node/node.multilayer.icon.arrow.js index a1faecdc7..5e043a9b7 100644 --- a/src/case/button/node/node.multilayer.icon.arrow.js +++ b/src/case/button/node/node.multilayer.icon.arrow.js @@ -19,9 +19,9 @@ BI.MultiLayerIconArrowNode = BI.inherit(BI.NodeButton, { this.node = BI.createWidget({ type: "bi.icon_arrow_node", iconCls: o.iconCls, - logic: { - dynamic: true - }, + //logic: { + // dynamic: true + //}, id: o.id, pId: o.pId, open: o.open, diff --git a/src/case/button/treeitem/item.multilayer.icon.treeleaf.js b/src/case/button/treeitem/item.multilayer.icon.treeleaf.js index 1cea15420..422381a20 100644 --- a/src/case/button/treeitem/item.multilayer.icon.treeleaf.js +++ b/src/case/button/treeitem/item.multilayer.icon.treeleaf.js @@ -19,9 +19,6 @@ BI.MultiLayerIconTreeLeafItem = BI.inherit(BI.BasicButton, { this.item = BI.createWidget({ type: "bi.icon_tree_leaf_item", iconCls: o.iconCls, - logic: { - dynamic: true - }, id: o.id, pId: o.pId, isFront: true, diff --git a/src/case/calendar/calendar.js b/src/case/calendar/calendar.js index d0db00233..c581428f7 100644 --- a/src/case/calendar/calendar.js +++ b/src/case/calendar/calendar.js @@ -29,12 +29,13 @@ BI.Calendar = BI.inherit(BI.Widget, { De.setFullYear(Y, M, D); log.ymd = [De.getFullYear(), De.getMonth(), De.getDate()]; - Date._MD[1] = Date.isLeap(log.ymd[0]) ? 29 : 28; + var MD = Date._MD.slice(0); + MD[1] = Date.isLeap(log.ymd[0]) ? 29 : 28; De.setFullYear(log.ymd[0], log.ymd[1], 1); log.FDay = De.getDay(); - log.PDay = Date._MD[M === 0 ? 11 : M - 1] - log.FDay + 1; + log.PDay = MD[M === 0 ? 11 : M - 1] - log.FDay + 1; log.NDay = 1; var items = []; @@ -45,7 +46,7 @@ BI.Calendar = BI.inherit(BI.Widget, { DD = i + log.PDay; MM === 1 && (YY -= 1); MM = MM === 1 ? 12 : MM - 1; - } else if (i >= log.FDay && i < log.FDay + Date._MD[log.ymd[1]]) { + } else if (i >= log.FDay && i < log.FDay + MD[log.ymd[1]]) { DD = i - log.FDay + 1; if (i - log.FDay + 1 === log.ymd[2]) { td.currentDay = true; @@ -166,6 +167,23 @@ BI.extend(BI.Calendar, { var page = (json.year - year) * 12; page += json.month - month; return page; + }, + getDateJSONByPage: function(v){ + var months = new Date().getMonth(); + var page = v; + + //对当前page做偏移,使到当前年初 + page = page + months; + + var year = BI.parseInt(page / 12); + if(page < 0 && page % 12 !== 0){ + year--; + } + var month = page >= 0 ? (page % 12) : ((12 + page % 12) % 12); + return { + year: new Date().getFullYear() + year, + month: month + } } }); diff --git a/src/case/colorpicker/editor.colorpicker.js b/src/case/colorpicker/editor.colorpicker.js index 97e9a04a2..ad89618a5 100644 --- a/src/case/colorpicker/editor.colorpicker.js +++ b/src/case/colorpicker/editor.colorpicker.js @@ -10,7 +10,7 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.ColorPickerEditor.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-color-picker-editor", - width: 190, + width: 200, height: 20 }) }, @@ -38,6 +38,7 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, { cls: "color-picker-editor-input", validationChecker: checker, errorText: BI.i18nText("BI-Color_Picker_Error_Text"), + allowBlank: true, value: 255, width: 35, height: 20 @@ -54,6 +55,22 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, { this.G = Ws[1]; this.B = Ws[2]; + this.none = BI.createWidget({ + type: "bi.checkbox" + }); + this.none.on(BI.Checkbox.EVENT_CHANGE, function () { + if (this.isSelected()) { + self.lastColor = self.getValue(); + self.setValue(""); + } else { + self.setValue(self.lastColor || "#000000"); + } + if (self.R.isValid() && self.G.isValid() && self.B.isValid()) { + self.colorShow.element.css("background-color", self.getValue()); + self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); + } + }); + BI.createWidget({ type: "bi.htape", element: this, @@ -66,32 +83,43 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, { width: 20 }, { el: this.R, - width: 35 + width: 32 }, { el: RGB[1], lgap: 10, width: 20 }, { el: this.G, - width: 35 + width: 32 }, { el: RGB[2], lgap: 10, width: 20 }, { el: this.B, - width: 35 + width: 32 + }, { + el: { + type: "bi.center_adapt", + items: [this.none] + }, + width: 20 }] }) }, setValue: function (color) { - color || (color = "#000000"); + if (!color) { + color = ""; + this.none.setSelected(true); + } else { + this.none.setSelected(false); + } this.colorShow.element.css("background-color", color); var json = BI.DOM.rgb2json(BI.DOM.hex2rgb(color)); - this.R.setValue(json.r); - this.G.setValue(json.g); - this.B.setValue(json.b); + this.R.setValue(BI.isNull(json.r) ? "" : json.r); + this.G.setValue(BI.isNull(json.g) ? "" : json.g); + this.B.setValue(BI.isNull(json.b) ? "" : json.b); }, getValue: function () { diff --git a/src/case/combo/combo.bubble.js b/src/case/combo/combo.bubble.js new file mode 100644 index 000000000..52e019a81 --- /dev/null +++ b/src/case/combo/combo.bubble.js @@ -0,0 +1,210 @@ +/** + * Created by GUY on 2017/2/8. + * + * @class BI.BubbleCombo + * @extends BI.Widget + */ +BI.BubbleCombo = BI.inherit(BI.Widget, { + _const: { + TRIANGLE_LENGTH: 6 + }, + _defaultConfig: function () { + return BI.extend(BI.BubbleCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-bubble-combo", + trigger: "click", + toggle: true, + direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right + isDefaultInit: false, + isNeedAdjustHeight: true,//是否需要高度调整 + isNeedAdjustWidth: true, + stopPropagation: false, + adjustLength: 0,//调整的距离 + // adjustXOffset: 0, + // adjustYOffset: 10, + hideChecker: BI.emptyFn, + offsetStyle: "left", //left,right,center + el: {}, + popup: {}, + }) + }, + _init: function () { + BI.BubbleCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + trigger: o.trigger, + toggle: o.toggle, + direction: o.direction, + isDefaultInit: o.isDefaultInit, + isNeedAdjustHeight: o.isNeedAdjustHeight, + isNeedAdjustWidth: o.isNeedAdjustWidth, + adjustLength: this._getAdjustLength(), + stopPropagation: o.stopPropagation, + adjustXOffset: 0, + adjustYOffset: 0, + hideChecker: o.hideChecker, + offsetStyle: o.offsetStyle, + el: o.el, + popup: BI.extend({ + type: "bi.bubble_popup_view" + }, o.popup), + }); + this.combo.on(BI.Combo.EVENT_TRIGGER_CHANGE, function () { + self.fireEvent(BI.BubbleCombo.EVENT_TRIGGER_CHANGE, arguments); + }); + this.combo.on(BI.Combo.EVENT_CHANGE, function () { + self.fireEvent(BI.BubbleCombo.EVENT_CHANGE, arguments); + }); + this.combo.on(BI.Combo.EVENT_EXPAND, function () { + self.fireEvent(BI.BubbleCombo.EVENT_EXPAND, arguments); + }); + this.combo.on(BI.Combo.EVENT_COLLAPSE, function () { + self.fireEvent(BI.BubbleCombo.EVENT_COLLAPSE, arguments); + }); + this.combo.on(BI.Combo.EVENT_AFTER_INIT, function () { + self.fireEvent(BI.BubbleCombo.EVENT_AFTER_INIT, arguments); + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, arguments); + }); + this.combo.on(BI.Combo.EVENT_AFTER_POPUPVIEW, function () { + self._showTriangle(); + self.fireEvent(BI.BubbleCombo.EVENT_AFTER_POPUPVIEW, arguments); + }); + this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { + self._hideTriangle(); + self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW, arguments); + }); + this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { + self.fireEvent(BI.BubbleCombo.EVENT_AFTER_HIDEVIEW, arguments); + }); + }, + + _getAdjustLength: function () { + return this._const.TRIANGLE_LENGTH + this.options.adjustLength; + }, + + _createTriangle: function (direction) { + var pos = {}, op = {}; + var adjustLength = this._getAdjustLength(); + switch (direction) { + case "left": + pos = { + top: 0, + bottom: 0, + left: -adjustLength + }; + op = {width: this._const.TRIANGLE_LENGTH}; + break; + case "right": + pos = { + top: 0, + bottom: 0, + right: -adjustLength + }; + op = {width: this._const.TRIANGLE_LENGTH}; + break; + case "top": + pos = { + left: 0, + right: 0, + top: -adjustLength + }; + op = {height: this._const.TRIANGLE_LENGTH}; + break; + case "bottom": + pos = { + left: 0, + right: 0, + bottom: -adjustLength + }; + op = {height: this._const.TRIANGLE_LENGTH}; + break; + default: + break; + } + this.triangle = BI.createWidget(op, { + type: "bi.center_adapt", + items: [{ + type: "bi.layout", + cls: "bubble-combo-triangle-" + direction + }] + }); + pos.el = this.triangle; + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [pos] + }) + }, + + _createLeftTriangle: function () { + this._createTriangle("left"); + }, + + _createRightTriangle: function () { + this._createTriangle("right"); + }, + + _createTopTriangle: function () { + this._createTriangle("top"); + }, + + _createBottomTriangle: function () { + this._createTriangle("bottom"); + }, + + _showTriangle: function () { + var pos = this.combo.getPopupPosition(); + switch (pos.dir) { + case "left,top": + case "left,bottom": + this._createLeftTriangle(); + this.combo.getView().showLine("right"); + break; + case "right,top": + case "right,bottom": + this._createRightTriangle(); + this.combo.getView().showLine("left"); + break; + case "top,left": + case "top,right": + this._createTopTriangle(); + this.combo.getView().showLine("bottom"); + break; + case "bottom,left": + case "bottom,right": + this._createBottomTriangle(); + this.combo.getView().showLine("top"); + break; + } + }, + + _hideTriangle: function () { + this.triangle && this.triangle.destroy(); + this.combo.getView().hideLine(); + }, + + hideView: function () { + this._hideTriangle(); + this.combo && this.combo.hideView(); + }, + + showView: function () { + this.combo && this.combo.showView(); + } +}); + +BI.BubbleCombo.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE"; +BI.BubbleCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.BubbleCombo.EVENT_EXPAND = "EVENT_EXPAND"; +BI.BubbleCombo.EVENT_COLLAPSE = "EVENT_COLLAPSE"; +BI.BubbleCombo.EVENT_AFTER_INIT = "EVENT_AFTER_INIT"; + + +BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.BubbleCombo.EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW"; +BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW"; +BI.BubbleCombo.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW"; +$.shortcut("bi.bubble_combo", BI.BubbleCombo); \ No newline at end of file diff --git a/src/case/combo/popup.bubble.bar.js b/src/case/combo/popup.bubble.bar.js new file mode 100644 index 000000000..4ad314978 --- /dev/null +++ b/src/case/combo/popup.bubble.bar.js @@ -0,0 +1,44 @@ +/** + * Created by GUY on 2017/2/8. + * + * @class BI.BubblePopupBarView + * @extends BI.BubblePopupView + */ +BI.BubblePopupBarView = BI.inherit(BI.BubblePopupView, { + _defaultConfig: function () { + return BI.extend(BI.BubblePopupBarView.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-bubble-bar-popup-view", + buttons: [{value: BI.i18nText(BI.i18nText("BI-Basic_Sure"))}, {value: BI.i18nText("BI-Basic_Cancel"), level: "ignore"}] + }) + }, + _init: function () { + BI.BubblePopupBarView.superclass._init.apply(this, arguments); + }, + _createToolBar: function () { + var o = this.options, self = this; + + var items = []; + BI.each(o.buttons.reverse(), function (i, buttonOpt) { + if(BI.isWidget(buttonOpt)){ + items.push(buttonOpt); + }else{ + items.push(BI.extend({ + type: 'bi.button', + height: 30, + handler: function (v) { + self.fireEvent(BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, v); + } + }, buttonOpt)) + } + }); + return BI.createWidget({ + type: 'bi.right_vertical_adapt', + height: 40, + hgap: 10, + bgap: 10, + items: items + }); + } +}); +BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON"; +$.shortcut("bi.bubble_bar_popup_view", BI.BubblePopupBarView); \ No newline at end of file diff --git a/src/case/combo/popup.bubble.js b/src/case/combo/popup.bubble.js new file mode 100644 index 000000000..2df2bc2a3 --- /dev/null +++ b/src/case/combo/popup.bubble.js @@ -0,0 +1,73 @@ +/** + * Created by GUY on 2017/2/8. + * + * @class BI.BubblePopupView + * @extends BI.PopupView + */ +BI.BubblePopupView = BI.inherit(BI.PopupView, { + _defaultConfig: function () { + var config = BI.BubblePopupView.superclass._defaultConfig.apply(this, arguments); + return BI.extend(config, { + baseCls: config.baseCls + " bi-bubble-popup-view" + }) + }, + _init: function () { + BI.BubblePopupView.superclass._init.apply(this, arguments); + }, + + showLine: function (direction) { + var pos = {}, op = {}; + switch (direction) { + case "left": + pos = { + top: 0, + bottom: 0, + left: -1 + }; + op = {width: 3}; + break; + case "right": + pos = { + top: 0, + bottom: 0, + right: -1 + }; + op = {width: 3}; + break; + case "top": + pos = { + left: 0, + right: 0, + top: -1 + }; + op = {height: 3}; + break; + case "bottom": + pos = { + left: 0, + right: 0, + bottom: -1 + }; + op = {height: 3}; + break; + default: + break; + } + this.line = BI.createWidget(op, { + type: "bi.layout", + cls: "bubble-popup-line" + }); + pos.el = this.line; + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [pos] + }) + }, + + hideLine: function () { + this.line && this.line.destroy(); + } +}); + +$.shortcut("bi.bubble_popup_view", BI.BubblePopupView); \ No newline at end of file diff --git a/src/case/editor/editor.record.js b/src/case/editor/editor.record.js index c4cd59331..7f9845d4f 100644 --- a/src/case/editor/editor.record.js +++ b/src/case/editor/editor.record.js @@ -5,9 +5,9 @@ * @extends BI.Single */ BI.RecordEditor = BI.inherit(BI.Single, { - _defaultConfig: function() { + _defaultConfig: function () { var conf = BI.RecordEditor.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf , { + return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-record-editor", hgap: 4, vgap: 2, @@ -24,7 +24,7 @@ BI.RecordEditor = BI.inherit(BI.Single, { }) }, - _init : function() { + _init: function () { BI.RecordEditor.superclass._init.apply(this, arguments); this.contents = []; var self = this, o = this.options; @@ -42,7 +42,7 @@ BI.RecordEditor = BI.inherit(BI.Single, { validationChecker: o.validationChecker, quitChecker: o.quitChecker, mouseOut: o.mouseOut, - allowBlank : o.allowBlank, + allowBlank: o.allowBlank, watermark: o.watermark, errorText: o.errorText }); @@ -54,64 +54,64 @@ BI.RecordEditor = BI.inherit(BI.Single, { this.editor.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }); - this.editor.on(BI.Editor.EVENT_FOCUS, function(){ + this.editor.on(BI.Editor.EVENT_FOCUS, function () { self._checkInputState(); self.fireEvent(BI.RecordEditor.EVENT_FOCUS, arguments); }); - this.editor.on(BI.Editor.EVENT_BLUR, function(){ + this.editor.on(BI.Editor.EVENT_BLUR, function () { self._checkInputState(); self.fireEvent(BI.RecordEditor.EVENT_BLUR, arguments); }); - this.editor.on(BI.Editor.EVENT_CLICK, function(){ + this.editor.on(BI.Editor.EVENT_CLICK, function () { self.fireEvent(BI.RecordEditor.EVENT_CLICK, arguments); }); - this.editor.on(BI.Editor.EVENT_CHANGE, function(){ + this.editor.on(BI.Editor.EVENT_CHANGE, function () { self.fireEvent(BI.RecordEditor.EVENT_CHANGE, arguments); }); - this.editor.on(BI.Editor.EVENT_KEY_DOWN, function(v){ + this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) { self.fireEvent(BI.RecordEditor.EVENT_KEY_DOWN, arguments); }); - this.editor.on(BI.Editor.EVENT_VALID, function(){ + this.editor.on(BI.Editor.EVENT_VALID, function () { self.fireEvent(BI.RecordEditor.EVENT_VALID, arguments); }); - this.editor.on(BI.Editor.EVENT_SPACE, function(){ + this.editor.on(BI.Editor.EVENT_SPACE, function () { self.fireEvent(BI.RecordEditor.EVENT_SPACE, arguments); }); - this.editor.on(BI.Editor.EVENT_CONFIRM, function(){ - self.setValue(self.getValue()); + this.editor.on(BI.Editor.EVENT_CONFIRM, function () { + self.setState(self.getValue()); self.editor.isValid() && self.editor.setValue(""); self.fireEvent(BI.RecordEditor.EVENT_CONFIRM, arguments); }); - this.editor.on(BI.Editor.EVENT_START, function(){ + this.editor.on(BI.Editor.EVENT_START, function () { self.fireEvent(BI.RecordEditor.EVENT_START, arguments); }); - this.editor.on(BI.Editor.EVENT_PAUSE, function(){ + this.editor.on(BI.Editor.EVENT_PAUSE, function () { self.fireEvent(BI.RecordEditor.EVENT_PAUSE, arguments); }); - this.editor.on(BI.Editor.EVENT_STOP, function(){ + this.editor.on(BI.Editor.EVENT_STOP, function () { self.fireEvent(BI.RecordEditor.EVENT_STOP, arguments); }); this.editor.on(BI.Editor.EVENT_ENTER, function () { self.fireEvent(BI.RecordEditor.EVENT_ENTER, arguments); }); - this.editor.on(BI.Editor.EVENT_BACKSPACE, function(){ + this.editor.on(BI.Editor.EVENT_BACKSPACE, function () { self._checkInputState(); }); - this.editor.on(BI.Editor.EVENT_REMOVE, function(){ - if(!BI.isEmpty(self.contents)){ + this.editor.on(BI.Editor.EVENT_REMOVE, function () { + if (!BI.isEmpty(self.contents)) { self.contents.pop().destroy(); self.setValue(self.getValue()); self._adjustInputWidth(); } }); - this.editor.on(BI.Editor.EVENT_ERROR, function(){ + this.editor.on(BI.Editor.EVENT_ERROR, function () { self.fireEvent(BI.RecordEditor.EVENT_ERROR, arguments); }); - this.editor.on(BI.Editor.EVENT_RESTRICT, function(){ + this.editor.on(BI.Editor.EVENT_RESTRICT, function () { self.fireEvent(BI.RecordEditor.EVENT_RESTRICT, arguments); }); - this.editor.on(BI.Editor.EVENT_EMPTY, function(){ + this.editor.on(BI.Editor.EVENT_EMPTY, function () { self.fireEvent(BI.RecordEditor.EVENT_EMPTY, arguments); }); BI.createWidget({ @@ -119,41 +119,41 @@ BI.RecordEditor = BI.inherit(BI.Single, { element: this, items: [this.textContainer, this.editor] }); - BI.Resizers.add(this.getName(), BI.bind(this._adjustInputWidth, this)); + BI.ResizeDetector.addResizeListener(this, BI.bind(this._adjustInputWidth, this)); this._adjustInputWidth(); }, - _adjustInputWidth: function(){ - BI.nextTick(BI.bind(function(){ + _adjustInputWidth: function () { + BI.nextTick(BI.bind(function () { this.editor.element.css("width", this.element.width() - this.textContainer.element.outerWidth() - 10); }, this)); }, - _checkInputState: function(){ - if(BI.isEmpty(this.contents)){ + _checkInputState: function () { + if (BI.isEmpty(this.contents)) { this.editor.enableWarterMark(); } else { this.editor.disableWarterMark(); } }, - focus: function(){ + focus: function () { this.editor.focus(); }, - blur: function(){ + blur: function () { this.editor.blur(); }, - isValid : function() { + isValid: function () { return this.editor.isValid(); }, - setErrorText: function(text){ + setErrorText: function (text) { this.editor.setErrorText(text); }, - getErrorText: function(){ + getErrorText: function () { return this.editor.getErrorText(); }, @@ -173,21 +173,21 @@ BI.RecordEditor = BI.inherit(BI.Single, { return this.editor.getValue(); }, - getState: function(){ - var values = BI.map(this.contents, function(i, lb){ + getState: function () { + var values = BI.map(this.contents, function (i, lb) { return lb.getText(); }); - if(BI.isNotEmptyString(this.editor.getValue())){ + if (BI.isNotEmptyString(this.editor.getValue())) { return values.concat([this.editor.getValue()]); } return values; }, - setState: function(v){ - BI.StateEditor.superclass.setValue.apply(this, arguments); - v = BI.isArray(v) ? v : (v == "" ? [] : [v]); + setState: function (v) { + BI.RecordEditor.superclass.setValue.apply(this, arguments); + v = BI.isArray(v) ? v : (v == "" ? [] : [v]); var contents = this.contents = []; - BI.each(v, function(i, lb){ + BI.each(v, function (i, lb) { contents.push(BI.createWidget({ type: "bi.label", height: 25, @@ -202,7 +202,7 @@ BI.RecordEditor = BI.inherit(BI.Single, { this._adjustInputWidth(); }, - destroy: function(){ + destroy: function () { BI.Resizers.remove(this.getName()); BI.RecordEditor.superclass.destroy.apply(this, arguments); } diff --git a/src/case/editor/editor.shelter.js b/src/case/editor/editor.shelter.js index b2b78f00b..ee5c710e6 100644 --- a/src/case/editor/editor.shelter.js +++ b/src/case/editor/editor.shelter.js @@ -207,6 +207,10 @@ BI.ShelterEditor = BI.inherit(BI.Single, { return this.editor.getLastValidValue(); }, + setTextStyle: function (style) { + this.text.setStyle(style); + }, + setValue: function (k) { this.editor.setValue(k); this._checkText(); diff --git a/src/case/editor/editor.sign.js b/src/case/editor/editor.sign.js index 2691cba9a..66de66a30 100644 --- a/src/case/editor/editor.sign.js +++ b/src/case/editor/editor.sign.js @@ -137,13 +137,15 @@ BI.SignEditor = BI.inherit(BI.Single, { _checkText: function () { var o = this.options; - if (this.editor.getValue() === "") { - this.text.setValue(o.watermark || ""); - this.text.element.addClass("bi-water-mark"); - } else { - this.text.setValue(this.editor.getValue()); - this.text.element.removeClass("bi-water-mark"); - } + BI.nextTick(BI.bind(function () { + if (this.editor.getValue() === "") { + this.text.setValue(o.watermark || ""); + this.text.element.addClass("bi-water-mark"); + } else { + this.text.setValue(this.editor.getValue()); + this.text.element.removeClass("bi-water-mark"); + } + }, this)); }, _showInput: function () { diff --git a/src/case/editor/editor.state.js b/src/case/editor/editor.state.js index 26e75d7bb..7bb1b0a2c 100644 --- a/src/case/editor/editor.state.js +++ b/src/case/editor/editor.state.js @@ -156,8 +156,10 @@ BI.StateEditor = BI.inherit(BI.Single, { }, focus: function () { - this._showInput(); - this.editor.focus(); + if (this.options.disabled === false) { + this._showInput(); + this.editor.focus(); + } }, blur: function () { @@ -199,6 +201,11 @@ BI.StateEditor = BI.inherit(BI.Single, { this.editor.setValue(k); }, + setEnable: function (v) { + this.text.setEnable(v); + this.editor.setEnable(v); + }, + getValue: function () { return this.editor.getValue(); }, @@ -212,26 +219,44 @@ BI.StateEditor = BI.inherit(BI.Single, { if (BI.isNumber(v)) { if (v === BI.Selection.All) { this.text.setText(BI.i18nText("BI-Select_All")); + this.text.setTitle(""); this.text.element.removeClass("state-editor-infinite-text"); } else if (v === BI.Selection.Multi) { this.text.setText(BI.i18nText("BI-Select_Part")); + this.text.setTitle(""); this.text.element.removeClass("state-editor-infinite-text"); } else { this.text.setText(BI.i18nText("BI-Unrestricted")); + this.text.setTitle(""); this.text.element.addClass("state-editor-infinite-text"); } return; } - if (!BI.isArray(v) || v.length === 1) { - this.text.setText(v); - this.text.setTitle(v); - this.text.element.removeClass("state-editor-infinite-text"); - } else if (BI.isEmpty(v)) { - this.text.setText(BI.i18nText("BI-Unrestricted")); - this.text.element.addClass("state-editor-infinite-text"); - } else { - this.text.setText(BI.i18nText("BI-Select_Part")); - this.text.element.removeClass("state-editor-infinite-text"); + if (BI.isString(v)) { + if (BI.isEmpty(v)) { + this.text.setText(BI.i18nText("BI-Unrestricted")); + this.text.setTitle(""); + this.text.element.addClass("state-editor-infinite-text"); + } else { + this.text.setText(v); + this.text.setTitle(v); + this.text.element.removeClass("state-editor-infinite-text"); + } + return; + } + if (BI.isArray(v)) { + if (BI.isEmpty(v)) { + this.text.setText(BI.i18nText("BI-Unrestricted")); + this.text.element.addClass("state-editor-infinite-text"); + } else if (v.length === 1) { + this.text.setText(v[0]); + this.text.setTitle(v[0]); + this.text.element.removeClass("state-editor-infinite-text"); + } else { + this.text.setText(BI.i18nText("BI-Select_Part")); + this.text.setTitle(""); + this.text.element.removeClass("state-editor-infinite-text"); + } } } }); diff --git a/src/case/editor/editor.state.simple.js b/src/case/editor/editor.state.simple.js index 9f2007d0b..3719d4609 100644 --- a/src/case/editor/editor.state.simple.js +++ b/src/case/editor/editor.state.simple.js @@ -199,6 +199,11 @@ BI.SimpleStateEditor = BI.inherit(BI.Single, { this.editor.setValue(k); }, + setEnable: function(v){ + this.text.setEnable(v); + this.editor.setEnable(v); + }, + getValue: function () { return this.editor.getValue(); }, @@ -211,10 +216,10 @@ BI.SimpleStateEditor = BI.inherit(BI.Single, { BI.SimpleStateEditor.superclass.setValue.apply(this, arguments); if (BI.isNumber(v)) { if (v === BI.Selection.All) { - this.text.setText(BI.i18nText("BI-Aleady_Selected")); + this.text.setText(BI.i18nText("BI-Already_Selected")); this.text.element.removeClass("state-editor-infinite-text"); } else if (v === BI.Selection.Multi) { - this.text.setText(BI.i18nText("BI-Aleady_Selected")); + this.text.setText(BI.i18nText("BI-Already_Selected")); this.text.element.removeClass("state-editor-infinite-text"); } else { this.text.setText(BI.i18nText("BI-Unrestricted")); @@ -230,7 +235,7 @@ BI.SimpleStateEditor = BI.inherit(BI.Single, { this.text.setText(BI.i18nText("BI-Unrestricted")); this.text.element.addClass("state-editor-infinite-text"); } else { - this.text.setText(BI.i18nText("BI-Aleady_Selected")); + this.text.setText(BI.i18nText("BI-Already_Selected")); this.text.element.removeClass("state-editor-infinite-text"); } } diff --git a/src/case/floatbox/floatboxsection.bar.js b/src/case/floatbox/floatboxsection.bar.js index 38df0d38c..17b904da2 100644 --- a/src/case/floatbox/floatboxsection.bar.js +++ b/src/case/floatbox/floatboxsection.bar.js @@ -7,7 +7,7 @@ BI.BarFloatSection = BI.inherit(BI.FloatSection, { _defaultConfig: function () { return BI.extend(BI.BarFloatSection.superclass._defaultConfig.apply(this, arguments), { - btns: [BI.i18nText(BI.i18nText("BI-Sure")), BI.i18nText("BI-Cancel")] + btns: [BI.i18nText(BI.i18nText("BI-Basic_Sure")), BI.i18nText("BI-Basic_Cancel")] }) }, @@ -73,7 +73,7 @@ BI.BarFloatSection = BI.inherit(BI.FloatSection, { BI.BarPopoverSection = BI.inherit(BI.PopoverSection, { _defaultConfig: function () { return BI.extend(BI.BarPopoverSection.superclass._defaultConfig.apply(this, arguments), { - btns: [BI.i18nText(BI.i18nText("BI-Sure")), BI.i18nText(BI.i18nText("BI-Cancel"))] + btns: [BI.i18nText(BI.i18nText("BI-Basic_Sure")), BI.i18nText(BI.i18nText("BI-Basic_Cancel"))] }) }, @@ -82,10 +82,11 @@ BI.BarPopoverSection = BI.inherit(BI.PopoverSection, { }, rebuildSouth: function (south) { - var self = this; + var self = this, o = this.options; this.sure = BI.createWidget({ type: 'bi.button', text: this.options.btns[0], + warningTitle: o.warningTitle, height: 30, value: 0, handler: function (v) { @@ -109,5 +110,9 @@ BI.BarPopoverSection = BI.inherit(BI.PopoverSection, { hgap: 5, items: [this.cancel, this.sure] }); + }, + + setConfirmButtonEnable: function(v){ + this.sure.setEnable(!!v); } }); \ No newline at end of file diff --git a/src/case/layer/layer.multiselect.js b/src/case/layer/layer.multiselect.js index 11b0ea1d6..c32a8777b 100644 --- a/src/case/layer/layer.multiselect.js +++ b/src/case/layer/layer.multiselect.js @@ -10,7 +10,7 @@ BI.MultiPopupView = BI.inherit(BI.PopupView, { var conf = BI.MultiPopupView.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-multi-list-view", - buttons: [BI.i18nText("BI-Sure")] + buttons: [BI.i18nText("BI-Basic_Sure")] }) }, diff --git a/src/case/logintimeout/login.timeout.js b/src/case/logintimeout/login.timeout.js new file mode 100644 index 000000000..17dbafd01 --- /dev/null +++ b/src/case/logintimeout/login.timeout.js @@ -0,0 +1,242 @@ +/** + * Created by Young's on 2016/8/30. + */ +BI.LoginTimeOut = BI.inherit(BI.BarPopoverSection, { + _defaultConfig: function () { + return BI.extend(BI.LoginTimeOut.superclass._defaultConfig.apply(this, arguments), {}) + }, + + _init: function () { + BI.LoginTimeOut.superclass._init.apply(this, arguments); + }, + + rebuildNorth: function (north) { + BI.createWidget({ + type: "bi.label", + element: north, + text: BI.i18nText("BI-Login_Timeout"), + height: 50, + textAlign: "left" + }) + }, + + rebuildCenter: function (center) { + var self = this, o = this.options; + var userNameInput = BI.createWidget({ + type: "bi.editor", + watermark: BI.i18nText("BI-Username"), + cls: "login-input", + allowBlank: true, + width: 300, + height: 30 + }); + var userNameMask = BI.createWidget({ + type: "bi.text_button", + width: 330, + height: 56, + cls: "error-mask" + }); + userNameMask.setVisible(false); + userNameMask.on(BI.TextButton.EVENT_CHANGE, function () { + userNameInput.focus(); + this.element.fadeOut(); + }); + + var userNameWrapper = BI.createWidget({ + type: "bi.absolute", + cls: "input-wrapper login-username-icon", + items: [{ + el: { + type: "bi.icon", + width: 26, + height: 26 + }, + top: 10, + left: 0 + }, { + el: userNameInput, + top: 8, + left: 30 + }, { + el: userNameMask, + top: 0, + left: 0 + }], + width: 330, + height: 56 + }); + + + var passwordInput = BI.createWidget({ + type: "bi.editor", + inputType: "password", + cls: "login-input", + allowBlank: true, + watermark: BI.i18nText("BI-Basic_Password"), + width: 300, + height: 30 + }); + var passwordMask = BI.createWidget({ + type: "bi.text_button", + width: 330, + height: 56, + cls: "error-mask" + }); + passwordMask.setVisible(false); + passwordMask.on(BI.TextButton.EVENT_CHANGE, function () { + passwordInput.focus(); + this.element.fadeOut(); + }); + + var passwordWrapper = BI.createWidget({ + type: "bi.absolute", + cls: "input-wrapper login-password-icon", + items: [{ + el: { + type: "bi.icon", + width: 26, + height: 26 + }, + top: 10, + left: 0 + }, { + el: passwordInput, + top: 8, + left: 30 + }, { + el: passwordMask, + top: 0, + left: 0 + }], + width: 330, + height: 56 + }); + + var loginButton = BI.createWidget({ + type: "bi.text_button", + text: BI.i18nText("BI-Basic_Login"), + cls: "login-button", + width: 330, + height: 50 + }); + loginButton.on(BI.TextButton.EVENT_CHANGE, function () { + if (BI.isEmptyString(userNameInput.getValue())) { + self._showMes(userNameMask, BI.i18nText("BI-Username_Not_Null")); + return; + } + if (BI.isEmptyString(passwordInput.getValue())) { + self._showMes(passwordMask, BI.i18nText("BI-Password_Not_Null")); + return; + } + + //反正是登录直接用FR的登录了 + FR.ajax({ + url: FR.servletURL + '?op=fs_load&cmd=login', + data: FR.cjkEncodeDO({ + fr_username: encodeURIComponent(userNameInput.getValue()), + fr_password: encodeURIComponent(passwordInput.getValue()), + fr_remember: self.keepLoginState.isSelected() + }), + type: 'POST', + async: false, + error: function () { + BI.Msg.toast("Error!"); + }, + complete: function (res, status) { + if (BI.isEmptyString(res.responseText)) { + self._showMes(userNameMask, BI.i18nText("BI-Authentication_Failed")); + return; + } + var signResult = FR.jsonDecode(res.responseText); + if (signResult.fail) { + //用户名和密码不匹配 + self._showMes(userNameMask, BI.i18nText("BI-Username_Password_Not_Correct")); + } else if (signResult.url) { + self.fireEvent(BI.LoginTimeOut.EVENT_LOGIN); + } + } + }); + }); + + var logo; + if (BI.isNotNull(window.top.FS)) { + logo = window.top.FS.config.logoImageID4FS; + } + BI.createWidget({ + type: "bi.absolute", + element: center, + cls: "bi-login-timeout-center", + items: [{ + el: { + type: "bi.center_adapt", + items: [{ + type: "bi.img", + src: FR.servletURL + (logo ? + '?op=fr_attach&cmd=ah_image&id=' + logo + '&isAdjust=false' : + '?op=resource&resource=/com/fr/bi/web/images/login/bi_logo.png'), + width: 120, + height: 120 + }], + width: 200, + height: 300 + }, + left: 0, + top: 0 + }, { + el: userNameWrapper, + top: 30, + left: 230 + }, { + el: passwordWrapper, + top: 100, + left: 230 + }, { + el: loginButton, + top: 200, + left: 230 + }] + }); + }, + + _showMes: function (widget, mes) { + widget.setText(mes); + widget.element.fadeIn(); + setTimeout(function () { + if (widget.element.isVisible()) { + widget.element.fadeOut(); + } + }, 5000); + }, + + rebuildSouth: function (south) { + this.keepLoginState = BI.createWidget({ + type: "bi.checkbox", + width: 16, + height: 16 + }); + BI.createWidget({ + type: "bi.absolute", + element: south, + cls: "bi-login-timeout-south", + items: [{ + el: this.keepLoginState, + top: 0, + left: 230 + }, { + el: { + type: "bi.label", + text: BI.i18nText("BI-Keep_Login_State"), + cls: "keep-state", + height: 30 + }, + top: -7, + left: 260 + }] + }) + } +}); +BI.extend(BI.LoginTimeOut, { + POPOVER_ID: "___popover__id___" +}); +BI.LoginTimeOut.EVENT_LOGIN = "EVENT_LOGIN"; +$.shortcut("bi.login_timeout", BI.LoginTimeOut); diff --git a/src/case/pager/pager.all.js b/src/case/pager/pager.all.count.js similarity index 57% rename from src/case/pager/pager.all.js rename to src/case/pager/pager.all.count.js index 16741bd10..d0451c6ee 100644 --- a/src/case/pager/pager.all.js +++ b/src/case/pager/pager.all.count.js @@ -1,36 +1,33 @@ /** - * 有总页数的分页控件 - * - * Created by GUY on 2015/9/8. - * @class BI.AllPagger - * @extends BI.Widget + * 有总页数和总行数的分页控件 + * Created by Young's on 2016/10/13. */ -BI.AllPagger = BI.inherit(BI.Widget, { +BI.AllCountPager = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.AllPagger.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-all-pager", - width: 96, - height: 25, + return BI.extend(BI.AllCountPager.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-all-count-pager", + height: 30, pages: 1, //必选项 - curr: 1 //初始化当前页, pages为数字时可用 + curr: 1, //初始化当前页, pages为数字时可用, + count: 1 //总行数 }) }, _init: function () { - BI.AllPagger.superclass._init.apply(this, arguments); + BI.AllCountPager.superclass._init.apply(this, arguments); var self = this, o = this.options; this.editor = BI.createWidget({ type: "bi.small_text_editor", cls: "pager-editor", validationChecker: function (v) { - return BI.isPositiveInteger(v); + return (self.rowCount.getValue() === 0 && v === "0") || BI.isPositiveInteger(v); }, hgap: 4, vgap: 0, value: o.curr, errorText: BI.i18nText("BI-Please_Input_Integer"), width: 30, - height: o.height - 2 + height: 20 }); this.pager = BI.createWidget({ type: "bi.pager", @@ -53,7 +50,7 @@ BI.AllPagger = BI.inherit(BI.Widget, { value: "prev", title: BI.i18nText("BI-Previous_Page"), warningTitle: BI.i18nText("BI-Current_Is_First_Page"), - height: o.height - 2, + height: 20, cls: "all-pager-prev column-pre-page-h-font" }, next: { @@ -61,7 +58,7 @@ BI.AllPagger = BI.inherit(BI.Widget, { value: "next", title: BI.i18nText("BI-Next_Page"), warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), - height: o.height - 2, + height: 20, cls: "all-pager-next column-next-page-h-font" }, @@ -73,10 +70,10 @@ BI.AllPagger = BI.inherit(BI.Widget, { this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { self.pager.setValue(BI.parseInt(self.editor.getValue())); - self.fireEvent(BI.AllPagger.EVENT_CHANGE); + self.fireEvent(BI.AllCountPager.EVENT_CHANGE); }); this.pager.on(BI.Pager.EVENT_CHANGE, function () { - self.fireEvent(BI.AllPagger.EVENT_CHANGE); + self.fireEvent(BI.AllCountPager.EVENT_CHANGE); }); this.pager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { self.editor.setValue(self.pager.getCurrentPage()); @@ -89,11 +86,34 @@ BI.AllPagger = BI.inherit(BI.Widget, { text: "/" + o.pages }); + this.rowCount = BI.createWidget({ + type: "bi.label", + height: o.height, + hgap: 5, + text: o.count, + title: o.count + }); + + var count = BI.createWidget({ + type: "bi.left", + items: [{ + type: "bi.label", + height: o.height, + text: BI.i18nText("BI-Basic_Total"), + width: 15 + }, this.rowCount, { + type: "bi.label", + height: o.height, + text: BI.i18nText("BI-Tiao_Data"), + width: 50, + textAlign: "left" + }] + }); BI.createWidget({ type: "bi.center_adapt", element: this, - columnSize: [30, "", 36], - items: [this.editor, this.allPages, this.pager] + columnSize: ["", 30, 40, 36], + items: [count, this.editor, this.allPages, this.pager] }) }, @@ -101,12 +121,18 @@ BI.AllPagger = BI.inherit(BI.Widget, { this.allPages.setText("/" + v); this.allPages.setTitle(v); this.pager.setAllPages(v); + this.editor.setEnable(v >= 1); }, setValue: function (v) { this.pager.setValue(v); }, + setCount: function (count) { + this.rowCount.setText(count); + this.rowCount.setTitle(count); + }, + getCurrentPage: function () { return this.pager.getCurrentPage(); }, @@ -119,9 +145,19 @@ BI.AllPagger = BI.inherit(BI.Widget, { return this.pager.hasNext(); }, + setPagerVisible: function (b) { + this.editor.setVisible(b); + this.allPages.setVisible(b); + this.pager.setVisible(b); + }, + + getAliasWidth: function () { + return this.options.width - 100; + }, + populate: function () { this.pager.populate(); } }); -BI.AllPagger.EVENT_CHANGE = "EVENT_CHANGE"; -$.shortcut("bi.all_pager", BI.AllPagger); \ No newline at end of file +BI.AllCountPager.EVENT_CHANGE = "EVENT_CHANGE"; +$.shortcut("bi.all_count_pager", BI.AllCountPager); \ No newline at end of file diff --git a/src/case/pager/pager.all.count.js~67b55d486e769f445942f15883303ca839ffd092 b/src/case/pager/pager.all.count.js~67b55d486e769f445942f15883303ca839ffd092 new file mode 100644 index 000000000..1d698b609 --- /dev/null +++ b/src/case/pager/pager.all.count.js~67b55d486e769f445942f15883303ca839ffd092 @@ -0,0 +1,163 @@ +/** + * 有总页数和总行数的分页控件 + * Created by Young's on 2016/10/13. + */ +BI.AllCountPager = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.AllCountPager.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-all-count-pager", + height: 30, + pages: 1, //必选项 + curr: 1, //初始化当前页, pages为数字时可用, + count: 1 //总行数 + }) + }, + _init: function () { + BI.AllCountPager.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget({ + type: "bi.small_text_editor", + cls: "pager-editor", + validationChecker: function (v) { + return (self.rowCount.getValue() == 0 && v === "0") || BI.isPositiveInteger(v); + }, + hgap: 4, + vgap: 0, + value: o.curr, + errorText: BI.i18nText("BI-Please_Input_Integer"), + width: 30, + height: 20 + }); + this.pager = BI.createWidget({ + type: "bi.detail_pager", + width: 36, + layouts: [{ + type: "bi.horizontal", + hgap: 1, + vgap: 1 + }], + + dynamicShow: false, + pages: o.pages, + curr: o.curr, + groups: 0, + + first: false, + last: false, + prev: { + type: "bi.icon_button", + value: "prev", + title: BI.i18nText("BI-Previous_Page"), + warningTitle: BI.i18nText("BI-Current_Is_First_Page"), + height: 20, + cls: "all-pager-prev column-pre-page-h-font" + }, + next: { + type: "bi.icon_button", + value: "next", + title: BI.i18nText("BI-Next_Page"), + warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), + height: 20, + cls: "all-pager-next column-next-page-h-font" + }, + + hasPrev: o.hasPrev, + hasNext: o.hasNext, + firstPage: o.firstPage, + lastPage: o.lastPage + }); + + this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { + self.pager.setValue(BI.parseInt(self.editor.getValue())); + self.fireEvent(BI.AllCountPager.EVENT_CHANGE); + }); + this.pager.on(BI.Pager.EVENT_CHANGE, function () { + self.fireEvent(BI.AllCountPager.EVENT_CHANGE); + }); + this.pager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { + self.editor.setValue(self.pager.getCurrentPage()); + }); + + this.allPages = BI.createWidget({ + type: "bi.label", + width: 30, + title: o.pages, + text: "/" + o.pages + }); + + this.rowCount = BI.createWidget({ + type: "bi.label", + height: o.height, + hgap: 5, + text: o.count, + title: o.count + }); + + var count = BI.createWidget({ + type: "bi.left", + items: [{ + type: "bi.label", + height: o.height, + text: BI.i18nText("BI-Basic_Total"), + width: 15 + }, this.rowCount, { + type: "bi.label", + height: o.height, + text: BI.i18nText("BI-Basic_Tiao") + BI.i18nText("BI-Basic_Data"), + width: 50, + textAlign: "left" + }] + }); + BI.createWidget({ + type: "bi.center_adapt", + element: this, + columnSize: ["", 30, 40, 36], + items: [count, this.editor, this.allPages, this.pager] + }) + }, + + setAllPages: function (v) { + this.allPages.setText("/" + v); + this.allPages.setTitle(v); + this.pager.setAllPages(v); + this.editor.setEnable(v >= 1); + }, + + setValue: function (v) { + this.pager.setValue(v); + }, + + setCount: function (count) { + this.rowCount.setValue(count); + this.rowCount.setTitle(count); + }, + + getCurrentPage: function () { + return this.pager.getCurrentPage(); + }, + + hasPrev: function () { + return this.pager.hasPrev(); + }, + + hasNext: function () { + return this.pager.hasNext(); + }, + + setPagerVisible: function (b) { + this.editor.setVisible(b); + this.allPages.setVisible(b); + this.pager.setVisible(b); + }, + + getAliasWidth: function () { + return this.options.width - 100; + }, + + populate: function () { + this.pager.populate(); + } +}); +BI.AllCountPager.EVENT_CHANGE = "EVENT_CHANGE"; +$.shortcut("bi.all_count_pager", BI.AllCountPager); \ No newline at end of file diff --git a/src/case/pager/pager.direction.js b/src/case/pager/pager.direction.js index 4cbfd156a..bba377d57 100644 --- a/src/case/pager/pager.direction.js +++ b/src/case/pager/pager.direction.js @@ -10,8 +10,7 @@ BI.DirectionPager = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.DirectionPager.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-direction-pager", - width: 108, - height: 25, + height: 30, horizontal: { pages: false, //总页数 curr: 1, //初始化当前页, pages为数字时可用 @@ -38,26 +37,26 @@ BI.DirectionPager = BI.inherit(BI.Widget, { var v = o.vertical, h = o.horizontal; this._createVPager(); this._createHPager(); - BI.createWidget({ + this.layout = BI.createWidget({ type: "bi.absolute", scrollable: false, element: this, items: [{ el: this.vpager, - top: 0, - left: -19 + top: 5, + right: 74 }, { el: this.vlabel, - top: 0, - left: 16 + top: 5, + right: 111 }, { el: this.hpager, - top: 0, - right: -19 + top: 5, + right: -9 }, { el: this.hlabel, - top: 0, - right: 16 + top: 5, + right: 28 }] }); }, @@ -67,17 +66,18 @@ BI.DirectionPager = BI.inherit(BI.Widget, { var v = o.vertical; this.vlabel = BI.createWidget({ type: "bi.label", - width: 20, - height: o.height, + width: 24, + height: 20, value: v.curr, title: v.curr }); this.vpager = BI.createWidget({ type: "bi.pager", - width: 72, + width: 76, layouts: [{ type: "bi.horizontal", - lgap: 20, + scrollx: false, + rgap: 24, vgap: 1 }], @@ -93,9 +93,9 @@ BI.DirectionPager = BI.inherit(BI.Widget, { value: "prev", title: BI.i18nText("BI-Up_Page"), warningTitle: BI.i18nText("BI-Current_Is_First_Page"), - height: o.height - 2, - iconWidth: o.height - 2, - iconHeight: o.height - 2, + height: 20, + iconWidth: 16, + iconHeight: 16, cls: "direction-pager-prev column-pre-page-h-font" }, next: { @@ -103,9 +103,9 @@ BI.DirectionPager = BI.inherit(BI.Widget, { value: "next", title: BI.i18nText("BI-Down_Page"), warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), - height: o.height - 2, - iconWidth: o.height - 2, - iconHeight: o.height - 2, + height: 20, + iconWidth: 16, + iconHeight: 16, cls: "direction-pager-next column-next-page-h-font" }, @@ -120,6 +120,7 @@ BI.DirectionPager = BI.inherit(BI.Widget, { }); this.vpager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { self.vlabel.setValue(this.getCurrentPage()); + self.vlabel.setTitle(this.getCurrentPage()); }); }, @@ -128,17 +129,18 @@ BI.DirectionPager = BI.inherit(BI.Widget, { var h = o.horizontal; this.hlabel = BI.createWidget({ type: "bi.label", - width: 20, - height: o.height, + width: 24, + height: 20, value: h.curr, title: h.curr }); this.hpager = BI.createWidget({ type: "bi.pager", - width: 72, + width: 76, layouts: [{ type: "bi.horizontal", - rgap: 20, + scrollx: false, + rgap: 24, vgap: 1 }], @@ -154,9 +156,9 @@ BI.DirectionPager = BI.inherit(BI.Widget, { value: "prev", title: BI.i18nText("BI-Left_Page"), warningTitle: BI.i18nText("BI-Current_Is_First_Page"), - height: o.height - 2, - iconWidth: o.height - 2, - iconHeight: o.height - 2, + height: 20, + iconWidth: 16, + iconHeight: 16, cls: "direction-pager-prev row-pre-page-h-font" }, next: { @@ -164,9 +166,9 @@ BI.DirectionPager = BI.inherit(BI.Widget, { value: "next", title: BI.i18nText("BI-Right_Page"), warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), - height: o.height - 2, - iconWidth: o.height - 2, - iconHeight: o.height - 2, + height: 20, + iconWidth: 16, + iconHeight: 16, cls: "direction-pager-next row-next-page-h-font" }, @@ -181,6 +183,7 @@ BI.DirectionPager = BI.inherit(BI.Widget, { }); this.hpager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { self.hlabel.setValue(this.getCurrentPage()); + self.hlabel.setTitle(this.getCurrentPage()); }); }, @@ -233,11 +236,41 @@ BI.DirectionPager = BI.inherit(BI.Widget, { populate: function () { this.vpager.populate(); this.hpager.populate(); + var vShow = false, hShow = false; + if (!this.hasHNext() && !this.hasHPrev()) { + this.setHPagerVisible(false); + } else { + this.setHPagerVisible(true); + hShow = true; + } + if (!this.hasVNext() && !this.hasVPrev()) { + this.setVPagerVisible(false); + } else { + this.setVPagerVisible(true); + vShow = true; + } + var num = [74, 111, -9, 28]; + var items = this.layout.attr("items"); + + if (vShow === true && hShow === true) { + items[0].right = num[0]; + items[1].right = num[1]; + items[2].right = num[2]; + items[3].right = num[3]; + } else if (vShow === true) { + items[0].right = num[2]; + items[1].right = num[3]; + } else if (hShow === true) { + items[2].right = num[2]; + items[3].right = num[3]; + } + this.layout.attr("items", items); + this.layout.resize(); }, - - refresh: function () { - this.vpager.refresh(); - this.hpager.refresh(); + + clear: function () { + this.vpager.attr("curr", 1); + this.hpager.attr("curr", 1); } }); BI.DirectionPager.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/case/pager/pager.js b/src/case/pager/pager.js new file mode 100644 index 000000000..2712f29c7 --- /dev/null +++ b/src/case/pager/pager.js @@ -0,0 +1,288 @@ +/** + * 分页控件 + * + * Created by GUY on 2015/8/31. + * @class BI.DetailPager + * @extends BI.Widget + */ +BI.DetailPager = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.DetailPager.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-detail-pager", + behaviors: {}, + layouts: [{ + type: "bi.horizontal", + hgap: 10, + vgap: 0 + }], + + dynamicShow: true, //是否动态显示上一页、下一页、首页、尾页, 若为false,则指对其设置使能状态 + //dynamicShow为false时以下两个有用 + dynamicShowFirstLast: false,//是否动态显示首页、尾页 + dynamicShowPrevNext: false,//是否动态显示上一页、下一页 + pages: false, //总页数 + curr: function () { + return 1; + }, //初始化当前页 + groups: 0, //连续显示分页数 + jump: BI.emptyFn, //分页的回调函数 + + first: false, //是否显示首页 + last: false, //是否显示尾页 + prev: "上一页", + next: "下一页", + + firstPage: 1, + lastPage: function () { //在万不得已时才会调用这个函数获取最后一页的页码, 主要作用于setValue方法 + return 1; + }, + hasPrev: BI.emptyFn, //pages不可用时有效 + hasNext: BI.emptyFn //pages不可用时有效 + }) + }, + _init: function () { + BI.DetailPager.superclass._init.apply(this, arguments); + var self = this; + this.currPage = BI.result(this.options, "curr"); + //翻页太灵敏 + this._lock = false; + this._debouce = BI.debounce(function () { + self._lock = false; + }, 300); + this._populate(); + }, + + _populate: function () { + var self = this, o = this.options, view = [], dict = {}; + this.empty(); + var pages = BI.result(o, "pages"); + var curr = BI.result(this, "currPage"); + var groups = BI.result(o, "groups"); + var first = BI.result(o, "first"); + var last = BI.result(o, "last"); + var prev = BI.result(o, "prev"); + var next = BI.result(o, "next"); + + if (pages === false) { + groups = 0; + first = false; + last = false; + } else { + groups > pages && (groups = pages); + } + + //计算当前组 + dict.index = Math.ceil((curr + ((groups > 1 && groups !== pages) ? 1 : 0)) / (groups === 0 ? 1 : groups)); + + //当前页非首页,则输出上一页 + if (((!o.dynamicShow && !o.dynamicShowPrevNext) || curr > 1) && prev !== false) { + if (BI.isKey(prev)) { + view.push({ + text: prev, + value: "prev", + disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false) + }) + } else { + view.push(BI.extend({ + disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false) + }, prev)); + } + } + + //当前组非首组,则输出首页 + if (((!o.dynamicShow && !o.dynamicShowFirstLast) || (dict.index > 1 && groups !== 0)) && first) { + view.push({ + text: first, + value: "first", + disabled: !(dict.index > 1 && groups !== 0) + }); + if (dict.index > 1 && groups !== 0) { + view.push({ + type: "bi.label", + cls: "page-ellipsis", + text: "\u2026" + }); + } + } + + //输出当前页组 + dict.poor = Math.floor((groups - 1) / 2); + dict.start = dict.index > 1 ? curr - dict.poor : 1; + dict.end = dict.index > 1 ? (function () { + var max = curr + (groups - dict.poor - 1); + return max > pages ? pages : max; + }()) : groups; + if (dict.end - dict.start < groups - 1) { //最后一组状态 + dict.start = dict.end - groups + 1; + } + var s = dict.start, e = dict.end; + if (first && last && (dict.index > 1 && groups !== 0) && (pages > groups && dict.end < pages && groups !== 0)) { + s++; + e--; + } + for (; s <= e; s++) { + if (s === curr) { + view.push({ + text: s, + value: s, + selected: true + }) + } else { + view.push({ + text: s, + value: s + }) + } + } + + //总页数大于连续分页数,且当前组最大页小于总页,输出尾页 + if (((!o.dynamicShow && !o.dynamicShowFirstLast) || (pages > groups && dict.end < pages && groups !== 0)) && last) { + if (pages > groups && dict.end < pages && groups !== 0) { + view.push({ + type: "bi.label", + cls: "page-ellipsis", + text: "\u2026" + }); + } + view.push({ + text: last, + value: "last", + disabled: !(pages > groups && dict.end < pages && groups !== 0) + }) + } + + //当前页不为尾页时,输出下一页 + dict.flow = !prev && groups === 0; + if (((!o.dynamicShow && !o.dynamicShowPrevNext) && next) || (curr !== pages && next || dict.flow)) { + view.push((function () { + if (BI.isKey(next)) { + if (pages === false) { + return {text: next, value: "next", disabled: o.hasNext(curr) === false} + } + return (dict.flow && curr === pages) + ? + {text: next, value: "next", disabled: true} + : + {text: next, value: "next", disabled: !(curr !== pages && next || dict.flow)}; + } else { + return BI.extend({ + disabled: pages === false ? o.hasNext(curr) === false : !(curr !== pages && next || dict.flow) + }, next); + } + }())); + } + + this.button_group = BI.createWidget({ + type: "bi.button_group", + element: this, + items: BI.createItems(view, { + cls: "page-item", + height: 23, + hgap: 10 + }), + behaviors: o.behaviors, + layouts: o.layouts + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { + if (self._lock === true) { + return; + } + self._lock = true; + self._debouce(); + if (type === BI.Events.CLICK) { + var v = self.button_group.getValue()[0]; + switch (v) { + case "first": + self.currPage = 1; + break; + case "last": + self.currPage = pages; + break; + case "prev": + self.currPage--; + break; + case "next": + self.currPage++; + break; + default: + self.currPage = v; + break; + } + o.jump.apply(self, [{ + pages: pages, + curr: self.currPage + }]); + self._populate(); + self.fireEvent(BI.DetailPager.EVENT_CHANGE, obj); + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.fireEvent(BI.DetailPager.EVENT_AFTER_POPULATE); + }, + + getCurrentPage: function () { + return this.currPage; + }, + + setAllPages: function (pages) { + this.options.pages = pages; + }, + + hasPrev: function (v) { + v || (v = 1); + var o = this.options; + var pages = this.options.pages; + return pages === false ? o.hasPrev(v) : v > 1; + }, + + hasNext: function (v) { + v || (v = 1); + var o = this.options; + var pages = this.options.pages; + return pages === false ? o.hasNext(v) : v < pages; + }, + + setValue: function (v) { + var o = this.options; + v = v | 0; + v = v < 1 ? 1 : v; + if (o.pages === false) { + var lastPage = BI.result(o, "lastPage"), firstPage = 1; + this.currPage = v > lastPage ? lastPage : ((firstPage = BI.result(o, "firstPage")), (v < firstPage ? firstPage : v)); + } else { + v = v > o.pages ? o.pages : v; + this.currPage = v; + } + this._populate(); + }, + + getValue: function () { + var val = this.button_group.getValue()[0]; + switch (val) { + case "prev": + return -1; + case "next": + return 1; + case "first": + return BI.MIN; + case "last": + return BI.MAX; + default : + return val; + } + }, + + attr: function (key, value) { + BI.DetailPager.superclass.attr.apply(this, arguments); + if (key === "curr") { + this.currPage = BI.result(this.options, "curr"); + } + }, + + populate: function () { + this._populate(); + } +}); +BI.DetailPager.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DetailPager.EVENT_AFTER_POPULATE = "EVENT_AFTER_POPULATE"; +$.shortcut("bi.detail_pager", BI.DetailPager); \ No newline at end of file diff --git a/src/case/pager/pager.number.js b/src/case/pager/pager.number.js deleted file mode 100644 index 02607345e..000000000 --- a/src/case/pager/pager.number.js +++ /dev/null @@ -1,116 +0,0 @@ -/** - * 显示页码的分页控件 - * - * Created by GUY on 2016/2/17. - * @class BI.NumberPager - * @extends BI.Widget - */ -BI.NumberPager = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.NumberPager.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-number-pager", - width: 95, - height: 25, - pages: false, //总页数 - curr: 1, //初始化当前页, pages为数字时可用 - - hasPrev: BI.emptyFn, - hasNext: BI.emptyFn, - firstPage: 1, - lastPage: BI.emptyFn - }) - }, - _init: function () { - BI.NumberPager.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.currentPage = o.curr; - this.label = BI.createWidget({ - type: "bi.label", - height: o.height - 2, - value: this.currentPage - }); - this.pager = BI.createWidget({ - type: "bi.pager", - width: 36, - layouts: [{ - type: "bi.horizontal", - hgap: 1, - vgap: 1 - }], - - dynamicShow: false, - pages: o.pages, - curr: o.curr, - groups: 0, - - first: false, - last: false, - prev: { - type: "bi.icon_button", - value: "prev", - title: BI.i18nText("BI-Previous_Page"), - warningTitle: BI.i18nText("BI-Current_Is_First_Page"), - height: o.height - 2, - iconWidth: o.height - 2, - iconHeight: o.height - 2, - cls: "number-pager-prev column-pre-page-h-font" - }, - next: { - type: "bi.icon_button", - value: "next", - title: BI.i18nText("BI-Next_Page"), - warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), - height: o.height - 2, - iconWidth: o.height - 2, - iconHeight: o.height - 2, - cls: "number-pager-next column-next-page-h-font" - }, - - hasPrev: o.hasPrev, - hasNext: o.hasNext, - firstPage: o.firstPage, - lastPage: o.lastPage - }); - - this.pager.on(BI.Pager.EVENT_CHANGE, function () { - if (self.getCurrentPage() !== self.pager.getCurrentPage()) { - self.currentPage = self.pager.getCurrentPage(); - self.fireEvent(BI.NumberPager.EVENT_CHANGE); - } - }); - this.pager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { - self.label.setValue(self.pager.getCurrentPage()); - }); - - BI.createWidget({ - type: "bi.center_adapt", - element: this, - columnSize: [20, "", 20, 36], - items: [{type: "bi.label", text: "第"}, this.label, {type: "bi.label", text: "页"}, this.pager] - }) - }, - - getCurrentPage: function () { - return this.currentPage; - }, - - hasPrev: function () { - return this.pager.hasPrev(); - }, - - hasNext: function () { - return this.pager.hasNext(); - }, - - setValue: function (v) { - this.currentPage = v; - this.pager.setValue(v); - }, - - populate: function () { - this.pager.populate(); - } -}); -BI.NumberPager.EVENT_CHANGE = "EVENT_CHANGE"; -$.shortcut("bi.number_pager", BI.NumberPager); \ No newline at end of file diff --git a/src/case/pager/pager.skip.js b/src/case/pager/pager.skip.js deleted file mode 100644 index b43ba5ae6..000000000 --- a/src/case/pager/pager.skip.js +++ /dev/null @@ -1,112 +0,0 @@ -/** - * 可以跳转的分页控件 - * - * Created by GUY on 2015/9/8. - * @class BI.SkipPager - * @extends BI.Widget - */ -BI.SkipPager = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SkipPager.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-skip-pager", - width: 110, - height: 25, - pages: false, //总页数 - curr: 1, //初始化当前页, pages为数字时可用 - - hasPrev: BI.emptyFn, - hasNext: BI.emptyFn, - firstPage: 1, - lastPage: BI.emptyFn - }) - }, - _init: function () { - BI.SkipPager.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.currentPage = o.curr; - this.editor = BI.createWidget({ - type: "bi.small_text_editor", - validationChecker: function (v) { - return BI.isPositiveInteger(v); - }, - hgap: 4, - vgap: 0, - value: o.curr, - errorText: BI.i18nText("BI-Please_Input_Integer"), - width: 30, - height: o.height - 2 - }); - this.pager = BI.createWidget({ - type: "bi.pager", - layouts: [{ - type: "bi.horizontal", - hgap: 1, - vgap: 1 - }], - - dynamicShow: false, - pages: o.pages, - curr: o.curr, - groups: 0, - - first: false, - last: false, - prev: { - type: "bi.icon_button", - value: "prev", - title: BI.i18nText("BI-Previous_Page"), - warningTitle: BI.i18nText("BI-Current_Is_First_Page"), - height: o.height - 2, - cls: "number-pager-prev column-pre-page-h-font" - }, - next: { - type: "bi.icon_button", - value: "next", - title: BI.i18nText("BI-Next_Page"), - warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), - height: o.height - 2, - cls: "number-pager-next column-next-page-h-font" - }, - - hasPrev: o.hasPrev, - hasNext: o.hasNext, - firstPage: o.firstPage, - lastPage: o.lastPage - }); - - this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { - self.pager.setValue(self.editor.getValue()); - }); - this.pager.on(BI.Pager.EVENT_CHANGE, function () { - if (self.getCurrentPage() !== self.pager.getCurrentPage()) { - self.currentPage = self.pager.getCurrentPage(); - self.fireEvent(BI.SkipPager.EVENT_CHANGE); - } - }); - this.pager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { - self.editor.setValue(self.pager.getCurrentPage()); - }); - - BI.createWidget({ - type: "bi.center_adapt", - element: this, - items: [{type: "bi.label", text: "第"}, this.editor, {type: "bi.label", text: "页"}, this.pager] - }) - }, - - getCurrentPage: function () { - return this.currentPage; - }, - - setValue: function(v){ - this.currentPage = v; - this.pager.setValue(v); - }, - - populate: function () { - this.pager.populate(); - } -}); -BI.SkipPager.EVENT_CHANGE = "EVENT_CHANGE"; -$.shortcut("bi.skip_pager", BI.SkipPager); \ No newline at end of file diff --git a/src/case/table/table.adaptive.js b/src/case/table/table.adaptive.js new file mode 100644 index 000000000..1ac21831f --- /dev/null +++ b/src/case/table/table.adaptive.js @@ -0,0 +1,235 @@ +/** + * 自适应宽度的表格 + * + * Created by GUY on 2016/2/3. + * @class BI.AdaptiveTable + * @extends BI.Widget + */ +BI.AdaptiveTable = BI.inherit(BI.Widget, { + + _const: { + perColumnSize: 100 + }, + + _defaultConfig: function () { + return BI.extend(BI.AdaptiveTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-adaptive-table", + el: { + type: "bi.resizable_table" + }, + isNeedResize: true, + isNeedFreeze: false,//是否需要冻结单元格 + freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 + + isNeedMerge: false,//是否需要合并单元格 + mergeCols: [], //合并的单元格列号 + mergeRule: BI.emptyFn, + + columnSize: [], + minColumnSize: [], + maxColumnSize: [], + + headerRowSize: 25, + rowSize: 25, + + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [] + }); + }, + + _init: function () { + BI.AdaptiveTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var data = this._digest(); + this.table = BI.createWidget(o.el, { + type: "bi.resizable_table", + element: this, + width: o.width, + height: o.height, + isNeedResize: o.isNeedResize, + isResizeAdapt: false, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: data.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: data.columnSize, + + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + + regionColumnSize: data.regionColumnSize, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + + header: o.header, + items: o.items, + //交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + self._populate(); + self.table.populate(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.columnSize = this.getColumnSize(); + self._populate(); + self.table.populate(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + }, + + _getFreezeColLength: function () { + return this.options.isNeedFreeze === true ? this.options.freezeCols.length : 0; + }, + + _digest: function () { + var o = this.options; + var columnSize = o.columnSize.slice(); + var regionColumnSize = o.regionColumnSize.slice(); + var freezeCols = o.freezeCols.slice(); + var regionSize = o.regionColumnSize[0]; + var freezeColLength = this._getFreezeColLength(); + if (!regionSize || regionSize > o.width - 10 || regionSize < 10) { + regionSize = (freezeColLength > o.columnSize.length / 2 ? 2 / 3 : 1 / 3) * o.width; + } + if (freezeColLength === 0) { + regionSize = 0; + } + if (freezeCols.length >= columnSize.length) { + freezeCols = []; + } + if (!BI.isNumber(columnSize[0])) { + columnSize = o.minColumnSize; + } + var summaryFreezeColumnSize = 0, summaryColumnSize = 0; + BI.each(columnSize, function (i, size) { + if (i < freezeColLength) { + summaryFreezeColumnSize += size; + } + summaryColumnSize += size; + }); + if (freezeColLength > 0) { + columnSize[freezeColLength - 1] = BI.clamp(regionSize - (summaryFreezeColumnSize - columnSize[freezeColLength - 1]), + o.minColumnSize[freezeColLength - 1] || 10, o.maxColumnSize[freezeColLength - 1] || Number.MAX_VALUE); + } + if (columnSize.length > 0) { + columnSize[columnSize.length - 1] = BI.clamp(o.width - BI.GridTableScrollbar.SIZE - regionSize - (summaryColumnSize - summaryFreezeColumnSize - columnSize[columnSize.length - 1]), + o.minColumnSize[columnSize.length - 1] || 10, o.maxColumnSize[columnSize.length - 1] || Number.MAX_VALUE); + } + regionColumnSize[0] = regionSize; + + return { + freezeCols: freezeCols, + columnSize: columnSize, + regionColumnSize: regionColumnSize + } + }, + + _populate: function () { + var o = this.options; + var data = this._digest(); + o.regionColumnSize = data.regionColumnSize; + o.columnSize = data.columnSize; + this.table.setColumnSize(data.columnSize); + this.table.setRegionColumnSize(data.regionColumnSize); + this.table.attr("freezeCols", data.freezeCols); + }, + + setWidth: function (width) { + BI.AdaptiveTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(width); + }, + + setHeight: function (height) { + BI.AdaptiveTable.superclass.setHeight.apply(this, arguments); + this.table.setHeight(height); + }, + + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + setRegionColumnSize: function (regionColumnSize) { + this.options.regionColumnSize = regionColumnSize; + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + getLeftHorizontalScroll: function () { + return this.table.getLeftHorizontalScroll(); + }, + + getRightHorizontalScroll: function () { + return this.table.getRightHorizontalScroll(); + }, + + attr: function (key, value) { + var v = BI.AdaptiveTable.superclass.attr.apply(this, arguments); + if (key === "freezeCols") { + return v; + } + return this.table.attr.apply(this.table, arguments); + }, + + restore: function () { + this.table.restore(); + }, + + populate: function (items) { + var self = this, o = this.options; + this._populate(); + this.table.populate.apply(this.table, arguments); + }, + + destroy: function () { + this.table.destroy(); + BI.AdaptiveTable.superclass.destroy.apply(this, arguments); + } +}); +$.shortcut('bi.adaptive_table', BI.AdaptiveTable); \ No newline at end of file diff --git a/src/case/table/table.dynamicsummarylayertree.js b/src/case/table/table.dynamicsummarylayertree.js index 31f5af1f5..219b904ab 100644 --- a/src/case/table/table.dynamicsummarylayertree.js +++ b/src/case/table/table.dynamicsummarylayertree.js @@ -10,11 +10,11 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.DynamicSummaryLayerTreeTable.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-dynamic-summary-layer-tree-table", - logic: { //冻结的页面布局逻辑 - dynamic: false - }, - isNeedResize: false,//是否需要调整列宽 + el: { + type: "bi.resizable_table" + }, + isNeedResize: true,//是否需要调整列宽 isResizeAdapt: true,//是否需要在调整列宽或区域宽度的时候它们自适应变化 isNeedFreeze: false,//是否需要冻结单元格 @@ -22,16 +22,18 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { isNeedMerge: true,//是否需要合并单元格 mergeCols: [], - mergeRule: function (row1, row2) { //合并规则, 默认相等时合并 - return BI.isEqual(row1, row2); - }, + mergeRule: BI.emptyFn, columnSize: [], headerRowSize: 25, footerRowSize: 25, rowSize: 25, - regionColumnSize: false, + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, header: [], footer: false, @@ -55,30 +57,34 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { _createHeader: function (vDeep) { var self = this, o = this.options; var header = o.header || [], crossHeader = o.crossHeader || []; - var items = BI.DynamicSummaryTreeTable.formatCrossItems(o.crossItems, vDeep); + var items = BI.TableTree.formatCrossItems(o.crossItems, vDeep, o.headerCellStyleGetter); var result = []; BI.each(items, function (row, node) { var c = [crossHeader[row]]; result.push(c.concat(node || [])); }); - var newHeader = this._formatColumns(header); - var deep = this._getHDeep(); - if (deep <= 0) { - newHeader.unshift({ - cls: "layer-tree-table-title", - text: BI.i18nText("BI-Row_Header") - }); - } else { - newHeader[0] = { - cls: "layer-tree-table-title", - text: BI.i18nText("BI-Row_Header") - }; + if (header && header.length > 0) { + var newHeader = this._formatColumns(header); + var deep = this._getHDeep(); + if (deep <= 0) { + newHeader.unshift({ + type: "bi.table_style_cell", + text: BI.i18nText("BI-Row_Header"), + styleGetter: o.headerCellStyleGetter + }); + } else { + newHeader[0] = { + type: "bi.table_style_cell", + text: BI.i18nText("BI-Row_Header"), + styleGetter: o.headerCellStyleGetter + }; + } + result.push(newHeader); } - result.push(newHeader); return result; }, - _formatItems: function (nodes, deep) { + _formatItems: function (nodes, header, deep) { var self = this, o = this.options; var result = []; @@ -102,19 +108,17 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { track(c, 0); }); if (BI.isArray(node.values)) { - var next = [{cls: "summary-cell last", text: BI.i18nText("BI-Summary_Values")}].concat(node.values); + var next = [{ + type: "bi.table_style_cell", + text: BI.i18nText("BI-Summary_Values"), + styleGetter: function () { + return o.summaryCellStyleGetter(true); + } + }].concat(node.values); result.push(next) } }); - return BI.DynamicSummaryTreeTable.formatSummaryItems(result, o.crossItems, deep); - }, - - _formatCols: function (cols, deep) { - deep = deep || this._getHDeep(); - cols = this._formatColumns(cols); - return BI.map(cols, function (i, c) { - return c - (deep - 1); - }) + return BI.DynamicSummaryTreeTable.formatSummaryItems(result, header, o.crossItems, 1); }, _formatColumns: function (columns, deep) { @@ -125,97 +129,124 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { return columns; }, - _init: function () { - BI.DynamicSummaryLayerTreeTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; + _formatFreezeCols: function () { + if (this.options.freezeCols.length > 0) { + return [0]; + } + return []; + }, + + _formatColumnSize: function (columnSize, deep) { + if (columnSize.length <= 0) { + return []; + } + var result = [0]; + deep = deep || this._getHDeep(); + BI.each(columnSize, function (i, size) { + if (i < deep) { + result[0] += size; + return; + } + result.push(size); + }); + return result; + }, + + _recomputeColumnSize: function () { + var o = this.options; + o.regionColumnSize = this.table.getRegionColumnSize(); + var columnSize = this.table.getColumnSize(); + if (o.freezeCols.length > 1) { + for (var i = 0; i < o.freezeCols.length - 1; i++) { + columnSize.splice(1, 0, 0); + } + } + o.columnSize = columnSize; + }, + + _digest: function () { + var o = this.options; var deep = this._getHDeep(); var vDeep = this._getVDeep(); var header = this._createHeader(vDeep); - var items = this._formatItems(o.items, deep); - this.table = BI.createWidget({ - type: "bi.table_view", + var data = this._formatItems(o.items, header, deep); + // var columnSize = o.columnSize.slice(); + // var minColumnSize = o.minColumnSize.slice(); + // var maxColumnSize = o.maxColumnSize.slice(); + // BI.removeAt(columnSize, data.deletedCols); + // BI.removeAt(minColumnSize, data.deletedCols); + // BI.removeAt(maxColumnSize, data.deletedCols); + return { + header: data.header, + items: data.items, + columnSize: this._formatColumnSize(o.columnSize, deep), + minColumnSize: this._formatColumns(o.minColumnSize, deep), + maxColumnSize: this._formatColumns(o.maxColumnSize, deep), + freezeCols: this._formatFreezeCols() + } + }, + + _init: function () { + BI.DynamicSummaryLayerTreeTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + var data = this._digest(); + this.table = BI.createWidget(o.el, { + type: "bi.resizable_table", element: this, - logic: o.logic, + width: o.width, + height: o.height, isNeedResize: o.isNeedResize, isResizeAdapt: o.isResizeAdapt, isNeedFreeze: o.isNeedFreeze, - freezeCols: this._formatCols(o.freezeCols, deep), + freezeCols: data.freezeCols, isNeedMerge: o.isNeedMerge, mergeCols: [], mergeRule: o.mergeRule, - columnSize: this._formatColumns(o.columnSize, deep), + columnSize: data.columnSize, + minColumnSize: data.minColumnSize, + maxColumnSize: data.maxColumnSize, headerRowSize: o.headerRowSize, - footerRowSize: o.footerRowSize, rowSize: o.rowSize, regionColumnSize: o.regionColumnSize, - header: header, - footer: this._formatColumns(o.footer, deep), - items: items - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments); + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + header: data.header, + items: data.items }); this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); }); - this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments); - }); this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + self._recomputeColumnSize(); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); }); - this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments); - }); this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + self._recomputeColumnSize(); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); }); }, - resize: function () { - this.table.resize(); + setWidth: function (width) { + BI.DynamicSummaryLayerTreeTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(width); }, - setColumnSize: function (columnSize) { - columnSize = this._formatColumns(columnSize); - this.table.setColumnSize(columnSize); + setHeight: function (height) { + BI.DynamicSummaryLayerTreeTable.superclass.setHeight.apply(this, arguments); + this.table.setHeight(height); }, - getColumnSize: function () { - var columnSize = this.table.getColumnSize(); - var deep = this._getHDeep(); - var pre = []; - if (deep > 0) { - pre = BI.makeArray(deep - 1, 0); - } - return pre.concat(columnSize); - }, - - getCalculateColumnSize: function () { - var columnSize = this.table.getCalculateColumnSize(); - var deep = this._getHDeep(); - var pre = []; - if (deep > 0) { - pre = BI.makeArray(deep - 1, ""); - } - return pre.concat(columnSize); + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; }, - setHeaderColumnSize: function (columnSize) { - columnSize = this._formatColumns(columnSize); - this.table.setHeaderColumnSize(columnSize); + getColumnSize: function () { + return this.options.columnSize; }, setRegionColumnSize: function (columnSize) { + this.options.regionColumnSize = columnSize; this.table.setRegionColumnSize(columnSize); }, @@ -223,30 +254,6 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { return this.table.getRegionColumnSize(); }, - getCalculateRegionColumnSize: function () { - return this.table.getCalculateRegionColumnSize(); - }, - - getCalculateRegionRowSize: function () { - return this.table.getCalculateRegionRowSize(); - }, - - getClientRegionColumnSize: function () { - return this.table.getClientRegionColumnSize(); - }, - - getScrollRegionColumnSize: function () { - return this.table.getScrollRegionColumnSize(); - }, - - getScrollRegionRowSize: function () { - return this.table.getScrollRegionRowSize(); - }, - - hasVerticalScroll: function () { - return this.table.hasVerticalScroll(); - }, - setVerticalScroll: function (scrollTop) { this.table.setVerticalScroll(scrollTop); }, @@ -271,10 +278,6 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { return this.table.getRightHorizontalScroll(); }, - getColumns: function () { - return this.table.getColumns(); - }, - attr: function (key, value) { var self = this; if (BI.isObject(key)) { @@ -286,22 +289,24 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { BI.DynamicSummaryLayerTreeTable.superclass.attr.apply(this, arguments); switch (key) { case "columnSize": - case "footer": - value = this._formatColumns(value); - break; + case "minColumnSize": + case "maxColumnSize": case "freezeCols": - value = value.length > 0 ? [0] : []; - break; case "mergeCols": - value = value.length > 0 ? [0] : []; - break; + return; } this.table.attr.apply(this.table, [key, value]); }, + restore: function () { + this.table.restore(); + }, + populate: function (items, header, crossItems, crossHeader) { var o = this.options; - o.items = items || []; + if (items) { + o.items = items; + } if (header) { o.header = header; } @@ -311,11 +316,12 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { if (crossHeader) { o.crossHeader = crossHeader; } - var deep = this._getHDeep(); - var vDeep = this._getVDeep(); - var header = this._createHeader(vDeep); - items = this._formatItems(o.items, deep); - this.table.populate(items, header); + var data = this._digest(); + this.table.setColumnSize(data.columnSize); + this.table.attr("minColumnSize", data.minColumnSize); + this.table.attr("maxColumnSize", data.maxColumnSize); + this.table.attr("freezeCols", data.freezeCols); + this.table.populate(data.items, data.header); }, destroy: function () { diff --git a/src/case/table/table.dynamicsummarytree.js b/src/case/table/table.dynamicsummarytree.js index b03f1f94c..747d6513e 100644 --- a/src/case/table/table.dynamicsummarytree.js +++ b/src/case/table/table.dynamicsummarytree.js @@ -10,11 +10,11 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.DynamicSummaryTreeTable.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-dynamic-summary-tree-table", - logic: { //冻结的页面布局逻辑 - dynamic: false + el: { + type: "bi.resizable_table" }, - isNeedResize: false,//是否需要调整列宽 + isNeedResize: true,//是否需要调整列宽 isResizeAdapt: true,//是否需要在调整列宽或区域宽度的时候它们自适应变化 isNeedFreeze: false,//是否需要冻结单元格 @@ -22,16 +22,18 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { isNeedMerge: true,//是否需要合并单元格 mergeCols: [], - mergeRule: function (row1, row2) { //合并规则, 默认相等时合并 - return BI.isEqual(row1, row2); - }, + mergeRule: BI.emptyFn, columnSize: [], headerRowSize: 25, footerRowSize: 25, rowSize: 25, - regionColumnSize: false, + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, header: [], footer: false, @@ -43,22 +45,6 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { }) }, - _createHeader: function (deep, vDeep) { - var self = this, o = this.options; - var header = o.header || [], crossHeader = o.crossHeader || []; - var items = BI.DynamicSummaryTreeTable.formatCrossItems(o.crossItems, vDeep); - var result = []; - BI.each(items, function (row, node) { - var c = []; - for (var i = 0; i < deep; i++) { - c.push(crossHeader[row]); - } - result.push(c.concat(node || [])); - }); - result.push(header); - return result; - }, - _getVDeep: function () { return this.options.crossHeader.length;//纵向深度 }, @@ -71,15 +57,12 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { _init: function () { BI.DynamicSummaryTreeTable.superclass._init.apply(this, arguments); var self = this, o = this.options; - var deep = this._getHDeep(); - var vDeep = this._getVDeep(); - var header = this._createHeader(deep, vDeep); - var items = BI.DynamicSummaryTreeTable.formatItems(o.items, deep); - items = BI.DynamicSummaryTreeTable.formatSummaryItems(items, o.crossItems, deep); - this.table = BI.createWidget({ - type: "bi.table_view", + var data = this._digest(); + this.table = BI.createWidget(o.el, { + type: "bi.resizable_table", element: this, - logic: o.logic, + width: o.width, + height: o.height, isNeedResize: o.isNeedResize, isResizeAdapt: o.isResizeAdapt, @@ -92,65 +75,74 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { columnSize: o.columnSize, headerRowSize: o.headerRowSize, - footerRowSize: o.footerRowSize, rowSize: o.rowSize, regionColumnSize: o.regionColumnSize, - header: header, - footer: o.footer, - items: items - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments); + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + + header: data.header, + items: data.items }); this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); }); - this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments); - }); this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); }); - this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments); - }); this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); }); }, - resize: function () { - this.table.resize(); + _digest: function () { + var o = this.options; + var deep = this._getHDeep(); + var vDeep = this._getVDeep(); + var header = BI.TableTree.formatHeader(o.header, o.crossHeader, o.crossItems, deep, vDeep, o.headerCellStyleGetter); + var items = BI.DynamicSummaryTreeTable.formatHorizontalItems(o.items, deep, false, o.summaryCellStyleGetter); + var data = BI.DynamicSummaryTreeTable.formatSummaryItems(items, header, o.crossItems, deep); + var columnSize = o.columnSize.slice(); + var minColumnSize = o.minColumnSize.slice(); + var maxColumnSize = o.maxColumnSize.slice(); + BI.removeAt(columnSize, data.deletedCols); + BI.removeAt(minColumnSize, data.deletedCols); + BI.removeAt(maxColumnSize, data.deletedCols); + return { + header: data.header, + items: data.items, + columnSize: columnSize, + minColumnSize: minColumnSize, + maxColumnSize: maxColumnSize + }; }, - setColumnSize: function (columnSize) { - this.table.setColumnSize(columnSize); + setWidth: function (width) { + BI.DynamicSummaryTreeTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(width); }, - getColumnSize: function () { - return this.table.getColumnSize(); + setHeight: function (height) { + BI.DynamicSummaryTreeTable.superclass.setHeight.apply(this, arguments); + this.table.setHeight(height); }, - getCalculateColumnSize: function () { - return this.table.getCalculateColumnSize(); + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; }, - setHeaderColumnSize: function (columnSize) { - this.table.setHeaderColumnSize(columnSize); + getColumnSize: function () { + return this.table.getColumnSize(); }, setRegionColumnSize: function (columnSize) { + this.options.regionColumnSize = columnSize; this.table.setRegionColumnSize(columnSize); }, @@ -158,30 +150,6 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { return this.table.getRegionColumnSize(); }, - getCalculateRegionColumnSize: function () { - return this.table.getCalculateRegionColumnSize(); - }, - - getCalculateRegionRowSize: function () { - return this.table.getCalculateRegionRowSize(); - }, - - getClientRegionColumnSize: function () { - return this.table.getClientRegionColumnSize(); - }, - - getScrollRegionColumnSize: function () { - return this.table.getScrollRegionColumnSize(); - }, - - getScrollRegionRowSize: function () { - return this.table.getScrollRegionRowSize(); - }, - - hasVerticalScroll: function () { - return this.table.hasVerticalScroll(); - }, - setVerticalScroll: function (scrollTop) { this.table.setVerticalScroll(scrollTop); }, @@ -206,18 +174,25 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { return this.table.getRightHorizontalScroll(); }, - getColumns: function () { - return this.table.getColumns(); - }, - - attr: function () { + attr: function (key) { BI.DynamicSummaryTreeTable.superclass.attr.apply(this, arguments); + switch (key) { + case "minColumnSize": + case "maxColumnSize": + return; + } this.table.attr.apply(this.table, arguments); }, + restore: function () { + this.table.restore(); + }, + populate: function (items, header, crossItems, crossHeader) { var o = this.options; - o.items = items || []; + if (items) { + o.items = items; + } if (header) { o.header = header; } @@ -227,12 +202,11 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { if (crossHeader) { o.crossHeader = crossHeader; } - var deep = this._getHDeep(); - var vDeep = this._getVDeep(); - var header = this._createHeader(deep, vDeep); - items = BI.DynamicSummaryTreeTable.formatItems(o.items, deep); - items = BI.DynamicSummaryTreeTable.formatSummaryItems(items, o.crossItems, deep); - this.table.populate(items, header); + var data = this._digest(); + this.table.setColumnSize(data.columnSize); + this.table.attr("minColumnSize", data.minColumnSize); + this.table.attr("maxColumnSize", data.maxColumnSize); + this.table.populate(data.items, data.header); }, destroy: function () { @@ -242,8 +216,8 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { }); BI.extend(BI.DynamicSummaryTreeTable, { - formatItems: function (nodes, deep, isCross) { - var self = this; + + formatHorizontalItems: function (nodes, deep, isCross, styleGetter) { var result = []; function track(store, node) { @@ -252,7 +226,7 @@ BI.extend(BI.DynamicSummaryTreeTable, { BI.each(node.children, function (index, child) { var next; if (store != -1) { - next = BI.clone(store); + next = store.slice(); next.push(node); } else { next = []; @@ -260,16 +234,21 @@ BI.extend(BI.DynamicSummaryTreeTable, { track(next, child); }); if (store != -1) { - next = BI.clone(store); + next = store.slice(); next.push(node); } else { next = []; } if ((store == -1 || node.children.length > 1) && BI.isNotEmptyArray(node.values)) { - var cls = store === -1 ? " last" : ""; - var id = BI.UUID(); + var summary = { + text: BI.i18nText("BI-Summary_Values"), + type: "bi.table_style_cell", + styleGetter: function () { + return styleGetter(store === -1) + } + }; for (var i = next.length; i < deep; i++) { - next.push({text: BI.i18nText("BI-Summary_Values"), tag: id, cls: "summary-cell" + cls}); + next.push(summary); } if (!isCross) { next = next.concat(node.values); @@ -287,7 +266,7 @@ BI.extend(BI.DynamicSummaryTreeTable, { return; } if (store != -1) { - next = BI.clone(store); + next = store.slice(); for (var i = next.length; i < deep; i++) { next.push(node); } @@ -315,19 +294,14 @@ BI.extend(BI.DynamicSummaryTreeTable, { //填充空位 BI.each(result, function (i, line) { var last = BI.last(line); - for (var i = line.length; i < deep; i++) { + for (var j = line.length; j < deep; j++) { line.push(last); } }); return result; }, - formatCrossItems: function (nodes, deep) { - var items = BI.DynamicSummaryTreeTable.formatItems(nodes, deep, true); - return BI.unzip(items); - }, - - formatSummaryItems: function (items, crossItems, deep) { + formatSummaryItems: function (items, header, crossItems, deep) { //求纵向需要去除的列 var cols = []; var leaf = 0; @@ -338,14 +312,20 @@ BI.extend(BI.DynamicSummaryTreeTable, { track(child); }); if (BI.isNotEmptyArray(node.values)) { - leaf++; if (node.children.length === 1) { - cols.push(leaf - 1 + deep); + for (var i = 0; i < node.values.length; i++) { + cols.push(leaf + i + deep); + } } + leaf += node.values.length; } return; } - leaf++; + if (node.values && node.values.length > 1) { + leaf += node.values.length; + } else { + leaf++; + } } BI.each(crossItems, function (i, node) { @@ -353,11 +333,14 @@ BI.extend(BI.DynamicSummaryTreeTable, { }); if (cols.length > 0) { + BI.each(header, function (i, node) { + BI.removeAt(node, cols); + }); BI.each(items, function (i, node) { BI.removeAt(node, cols); - }) + }); } - return items; + return {items: items, header: header, deletedCols: cols}; } }); diff --git a/src/case/table/table.layertree.cell.js b/src/case/table/table.layertree.cell.js deleted file mode 100644 index 50ba6812c..000000000 --- a/src/case/table/table.layertree.cell.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Created by GUY on 2016/5/7. - * @class BI.LayerTreeTableCell - * @extends BI.Single - */ -BI.LayerTreeTableCell = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.LayerTreeTableCell.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-layer-tree-table-cell", - layer: 0, - text: "" - }) - }, - - _init: function () { - BI.LayerTreeTableCell.superclass._init.apply(this, arguments); - var o = this.options; - BI.createWidget({ - type: "bi.label", - element: this, - textAlign: "left", - whiteSpace: "nowrap", - height: o.height, - text: o.text, - value: o.value, - lgap: 5 + 30 * o.layer, - rgap: 5 - }) - } -}); - -$.shortcut("bi.layer_tree_table_cell", BI.LayerTreeTableCell); \ No newline at end of file diff --git a/src/case/table/table.layertree.js b/src/case/table/table.layertree.js index f2d79940d..70c5f722b 100644 --- a/src/case/table/table.layertree.js +++ b/src/case/table/table.layertree.js @@ -10,8 +10,8 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.LayerTreeTable.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-layer-tree-table", - logic: { //冻结的页面布局逻辑 - dynamic: false + el: { + type: "bi.resizable_table" }, isNeedResize: false,//是否需要调整列宽 @@ -22,19 +22,22 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { isNeedMerge: true,//是否需要合并单元格 mergeCols: [], - mergeRule: function (row1, row2) { //合并规则, 默认相等时合并 - return BI.isEqual(row1, row2); - }, + mergeRule: BI.emptyFn, columnSize: [], + minColumnSize: [], + maxColumnSize: [], + headerRowSize: 25, - footerRowSize: 25, rowSize: 25, - regionColumnSize: false, + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, header: [], - footer: false, items: [], //交叉表头 @@ -55,31 +58,35 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { _createHeader: function (vDeep) { var self = this, o = this.options; var header = o.header || [], crossHeader = o.crossHeader || []; - var items = BI.TableTree.formatCrossItems(o.crossItems, vDeep); + var items = BI.TableTree.formatCrossItems(o.crossItems, vDeep, o.headerCellStyleGetter); var result = []; BI.each(items, function (row, node) { var c = [crossHeader[row]]; result.push(c.concat(node || [])); }); - var newHeader = this._formatColumns(header); - var deep = this._getHDeep(); - if (deep <= 0) { - newHeader.unshift({ - cls: "layer-tree-table-title", - text: BI.i18nText("BI-Row_Header") - }); - } else { - newHeader[0] = { - cls: "layer-tree-table-title", - text: BI.i18nText("BI-Row_Header") - }; + if (header && header.length > 0) { + var newHeader = this._formatColumns(header); + var deep = this._getHDeep(); + if (deep <= 0) { + newHeader.unshift({ + type: "bi.table_style_cell", + text: BI.i18nText("BI-Row_Header"), + styleGetter: o.headerCellStyleGetter + }); + } else { + newHeader[0] = { + type: "bi.table_style_cell", + text: BI.i18nText("BI-Row_Header"), + styleGetter: o.headerCellStyleGetter + }; + } + result.push(newHeader); } - result.push(newHeader); return result; }, _formatItems: function (nodes) { - var self = this; + var self = this, o = this.options; var result = []; function track(node, layer) { @@ -102,21 +109,17 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { track(c, 0); }); if (BI.isArray(node.values)) { - var next = [{cls: "summary-cell last", text: BI.i18nText("BI-Summary_Values")}].concat(node.values); + var next = [{ + type: "bi.table_style_cell", text: BI.i18nText("BI-Summary_Values"), styleGetter: function () { + return o.summaryCellStyleGetter(true); + } + }].concat(node.values); result.push(next) } }); return result; }, - _formatCols: function (cols, deep) { - deep = deep || this._getHDeep(); - cols = this._formatColumns(cols); - return BI.map(cols, function (i, c) { - return c - (deep - 1); - }) - }, - _formatColumns: function (columns, deep) { if (BI.isNotEmptyArray(columns)) { deep = deep || this._getHDeep(); @@ -125,69 +128,99 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { return columns; }, + _formatFreezeCols: function () { + if (this.options.freezeCols.length > 0) { + return [0]; + } + return []; + }, + + _formatColumnSize: function (columnSize, deep) { + if (columnSize.length <= 0) { + return []; + } + var result = [0]; + deep = deep || this._getHDeep(); + BI.each(columnSize, function (i, size) { + if (i < deep) { + result[0] += size; + return; + } + result.push(size); + }); + return result; + }, + + _digest: function () { + var o = this.options; + var deep = this._getHDeep(); + var vDeep = this._getVDeep(); + return { + header: this._createHeader(vDeep), + items: this._formatItems(o.items), + columnSize: this._formatColumnSize(o.columnSize, deep), + minColumnSize: this._formatColumns(o.minColumnSize, deep), + maxColumnSize: this._formatColumns(o.maxColumnSize, deep), + freezeCols: this._formatFreezeCols() + } + }, + _init: function () { BI.LayerTreeTable.superclass._init.apply(this, arguments); var self = this, o = this.options; - var deep = this._getHDeep(); - var vDeep = this._getVDeep(); - var header = this._createHeader(vDeep); - var items = this._formatItems(o.items); - this.table = BI.createWidget({ - type: "bi.table_view", + + var data = this._digest(); + this.table = BI.createWidget(o.el, { + type: "bi.resizable_table", element: this, - logic: o.logic, + width: o.width, + height: o.height, isNeedResize: o.isNeedResize, isResizeAdapt: o.isResizeAdapt, isNeedFreeze: o.isNeedFreeze, - freezeCols: this._formatCols(o.freezeCols, deep), + freezeCols: data.freezeCols, isNeedMerge: o.isNeedMerge, mergeCols: [], mergeRule: o.mergeRule, - columnSize: this._formatColumns(o.columnSize, deep), + columnSize: data.columnSize, + minColumnSize: data.minColumnSize, + maxColumnSize: data.maxColumnSize, headerRowSize: o.headerRowSize, - footerRowSize: o.footerRowSize, rowSize: o.rowSize, regionColumnSize: o.regionColumnSize, - header: header, - footer: this._formatColumns(o.footer, deep), - items: items - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments); + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + header: data.header, + items: data.items }); this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); }); - this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments); - }); this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); }); - this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments); - }); this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); }); }, - resize: function () { - this.table.resize(); + setWidth: function (width) { + BI.LayerTreeTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(width); + }, + + setHeight: function (height) { + BI.LayerTreeTable.superclass.setHeight.apply(this, arguments); + this.table.setHeight(height); }, setColumnSize: function (columnSize) { - columnSize = this._formatColumns(columnSize); - this.table.setColumnSize(columnSize); + this.options.columnSize = columnSize; }, getColumnSize: function () { @@ -195,27 +228,13 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { var deep = this._getHDeep(); var pre = []; if (deep > 0) { - pre = BI.makeArray(deep - 1, 0); - } - return pre.concat(columnSize); - }, - - getCalculateColumnSize: function () { - var columnSize = this.table.getCalculateColumnSize(); - var deep = this._getHDeep(); - var pre = []; - if (deep > 0) { - pre = BI.makeArray(deep - 1, ""); + pre = BI.makeArray(deep, columnSize[0] / deep); } - return pre.concat(columnSize); - }, - - setHeaderColumnSize: function (columnSize) { - columnSize = this._formatColumns(columnSize); - this.table.setHeaderColumnSize(columnSize); + return pre.concat(columnSize.slice(1)); }, setRegionColumnSize: function (columnSize) { + this.options.regionColumnSize = columnSize; this.table.setRegionColumnSize(columnSize); }, @@ -223,30 +242,6 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { return this.table.getRegionColumnSize(); }, - getCalculateRegionColumnSize: function () { - return this.table.getCalculateRegionColumnSize(); - }, - - getCalculateRegionRowSize: function () { - return this.table.getCalculateRegionRowSize(); - }, - - getClientRegionColumnSize: function () { - return this.table.getClientRegionColumnSize(); - }, - - getScrollRegionColumnSize: function () { - return this.table.getScrollRegionColumnSize(); - }, - - getScrollRegionRowSize: function () { - return this.table.getScrollRegionRowSize(); - }, - - hasVerticalScroll: function () { - return this.table.hasVerticalScroll(); - }, - setVerticalScroll: function (scrollTop) { this.table.setVerticalScroll(scrollTop); }, @@ -271,10 +266,6 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { return this.table.getRightHorizontalScroll(); }, - getColumns: function () { - return this.table.getColumns(); - }, - attr: function (key, value) { var self = this; if (BI.isObject(key)) { @@ -286,19 +277,19 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { BI.LayerTreeTable.superclass.attr.apply(this, arguments); switch (key) { case "columnSize": - case "footer": - value = this._formatColumns(value); - break; + case "minColumnSize": + case "maxColumnSize": case "freezeCols": - value = value.length > 0 ? [0] : []; - break; case "mergeCols": - value = value.length > 0 ? [0] : []; - break; + return; } this.table.attr.apply(this.table, [key, value]); }, + restore: function () { + this.table.restore(); + }, + populate: function (items, header, crossItems, crossHeader) { var o = this.options; o.items = items || []; @@ -311,10 +302,12 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { if (crossHeader) { o.crossHeader = crossHeader; } - var vDeep = this._getVDeep(); - var header = this._createHeader(vDeep); - items = this._formatItems(o.items); - this.table.populate(items, header); + var data = this._digest(); + this.table.setColumnSize(data.columnSize); + this.table.attr("freezeCols", data.freezeCols); + this.table.attr("minColumnSize", data.minColumnSize); + this.table.attr("maxColumnSize", data.maxColumnSize); + this.table.populate(data.items, data.header); }, destroy: function () { diff --git a/src/case/table/table.style.cell.js b/src/case/table/table.style.cell.js new file mode 100644 index 000000000..ff7762d9d --- /dev/null +++ b/src/case/table/table.style.cell.js @@ -0,0 +1,46 @@ +/** + * + * Created by GUY on 2016/5/26. + * @class BI.TableStyleCell + * @extends BI.Single + */ +BI.TableStyleCell = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.TableStyleCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-table-style-cell", + styleGetter: BI.emptyFn + }); + }, + + _init: function () { + BI.TableStyleCell.superclass._init.apply(this, arguments); + var o = this.options; + this.text = BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + forceCenter: true, + hgap: 5, + text: o.text + }); + this._digestStyle(); + }, + + _digestStyle: function () { + var o = this.options; + var style = o.styleGetter(); + if (style) { + this.text.element.css(style); + } + }, + + setText: function (text) { + this.text.setText(text); + }, + + populate: function () { + this._digestStyle(); + } +}); +$.shortcut('bi.table_style_cell', BI.TableStyleCell); \ No newline at end of file diff --git a/src/case/table/table.tree.js b/src/case/table/table.tree.js new file mode 100644 index 000000000..4d78a07c3 --- /dev/null +++ b/src/case/table/table.tree.js @@ -0,0 +1,330 @@ +/** + * + * 树状结构的表格 + * + * Created by GUY on 2015/9/22. + * @class BI.TableTree + * @extends BI.Widget + */ +BI.TableTree = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.TableTree.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-table-tree", + el: { + type: "bi.resizable_table" + }, + isNeedResize: true,//是否需要调整列宽 + isResizeAdapt: true,//是否需要在调整列宽或区域宽度的时候它们自适应变化 + + freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为tree时生效 + + isNeedMerge: true,//是否需要合并单元格 + mergeCols: [], + mergeRule: BI.emptyFn, + + columnSize: [], + minColumnSize: [], + maxColumnSize: [], + headerRowSize: 25, + rowSize: 25, + + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, + + header: [], + items: [], + + //交叉表头 + crossHeader: [], + crossItems: [] + }) + }, + + _getVDeep: function () { + return this.options.crossHeader.length;//纵向深度 + }, + + _getHDeep: function () { + var o = this.options; + return Math.max(o.mergeCols.length, o.freezeCols.length, BI.TableTree.maxDeep(o.items) - 1); + }, + + _init: function () { + BI.TableTree.superclass._init.apply(this, arguments); + var self = this, o = this.options; + var data = this._digest(); + this.table = BI.createWidget(o.el, { + type: "bi.resizable_table", + element: this, + width: o.width, + height: o.height, + isNeedResize: o.isNeedResize, + isResizeAdapt: o.isResizeAdapt, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: o.columnSize, + minColumnSize: o.minColumnSize, + maxColumnSize: o.maxColumnSize, + + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + + header: data.header, + items: data.items + }); + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + }, + + _digest: function () { + var self = this, o = this.options; + var deep = this._getHDeep(); + var vDeep = this._getVDeep(); + var header = BI.TableTree.formatHeader(o.header, o.crossHeader, o.crossItems, deep, vDeep, o.headerCellStyleGetter); + var items = BI.TableTree.formatItems(o.items, deep, false, o.summaryCellStyleGetter); + return { + header: header, + items: items + } + }, + + setWidth: function (width) { + BI.TableTree.superclass.setWidth.apply(this, arguments); + this.table.setWidth(width); + }, + + setHeight: function (height) { + BI.TableTree.superclass.setHeight.apply(this, arguments); + this.table.setHeight(height); + }, + + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + setRegionColumnSize: function (columnSize) { + this.options.regionColumnSize = columnSize; + this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + getLeftHorizontalScroll: function () { + return this.table.getLeftHorizontalScroll(); + }, + + getRightHorizontalScroll: function () { + return this.table.getRightHorizontalScroll(); + }, + + attr: function () { + BI.TableTree.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + }, + + restore: function () { + this.table.restore(); + }, + + populate: function (items, header, crossItems, crossHeader) { + var o = this.options; + if (items) { + o.items = items || []; + } + if (header) { + o.header = header; + } + if (crossItems) { + o.crossItems = crossItems; + } + if (crossHeader) { + o.crossHeader = crossHeader; + } + var data = this._digest(); + this.table.populate(data.items, data.header); + }, + + destroy: function () { + this.table.destroy(); + BI.TableTree.superclass.destroy.apply(this, arguments); + } +}); + +BI.extend(BI.TableTree, { + formatHeader: function (header, crossHeader, crossItems, hDeep, vDeep, styleGetter) { + var items = BI.TableTree.formatCrossItems(crossItems, vDeep, styleGetter); + var result = []; + for (var i = 0; i < vDeep; i++) { + var c = []; + for (var j = 0; j < hDeep; j++) { + c.push(crossHeader[i]); + } + result.push(c.concat(items[i] || [])); + } + if (header && header.length > 0) { + result.push(header); + } + return result; + }, + + formatItems: function (nodes, deep, isCross, styleGetter) { + var self = this; + var result = []; + + function track(store, node) { + var next; + if (BI.isArray(node.children)) { + BI.each(node.children, function (index, child) { + var next; + if (store != -1) { + next = store.slice(); + next.push(node); + } else { + next = []; + } + track(next, child); + }); + if (store != -1) { + next = store.slice(); + next.push(node); + } else { + next = []; + } + if (/**(store == -1 || node.children.length > 1) &&**/ BI.isNotEmptyArray(node.values)) { + var summary = { + text: BI.i18nText("BI-Summary_Values"), + type: "bi.table_style_cell", + styleGetter: function () { + return styleGetter(store === -1) + } + }; + for (var i = next.length; i < deep; i++) { + next.push(summary); + } + if (!isCross) { + next = next.concat(node.values); + } + if (next.length > 0) { + if (!isCross) { + result.push(next); + } else { + for (var k = 0, l = node.values.length; k < l; k++) { + result.push(next); + } + } + } + } + + return; + } + if (store != -1) { + next = store.slice(); + for (var i = next.length; i < deep; i++) { + next.push(node); + } + } else { + next = []; + } + if (!isCross && BI.isArray(node.values)) { + next = next.concat(node.values); + } + if (isCross && BI.isArray(node.values)) { + for (var i = 0, len = node.values.length; i < len - 1; i++) { + if (next.length > 0) { + result.push(next); + } + } + } + if (next.length > 0) { + result.push(next); + } + } + + BI.each(nodes, function (i, node) { + track(-1, node); + }); + //填充空位 + BI.each(result, function (i, line) { + var last = BI.last(line); + for (var j = line.length; j < deep; j++) { + line.push(last); + } + }); + return result; + }, + + formatCrossItems: function (nodes, deep, styleGetter) { + var items = BI.TableTree.formatItems(nodes, deep, true, styleGetter); + return BI.unzip(items); + }, + + maxDeep: function (nodes) { + function track(deep, node) { + var d = deep; + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + d = Math.max(d, track(deep + 1, child)); + }); + } + return d; + } + + var deep = 1; + if (BI.isObject(nodes)) { + BI.each(nodes, function (i, node) { + deep = Math.max(deep, track(1, node)); + }); + } + return deep; + } +}); + +$.shortcut("bi.table_tree", BI.TableTree); \ No newline at end of file diff --git a/src/case/table/tabler.js b/src/case/table/tabler.js deleted file mode 100644 index 42615420d..000000000 --- a/src/case/table/tabler.js +++ /dev/null @@ -1,92 +0,0 @@ -/** - * 分页table - * - * Created by GUY on 2015/9/8. - * @class BI.Tabler - * @extends BI.Widget - */ -BI.Tabler = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.Tabler.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-tabler", - - pager: {}, - - layouts: [{ - type: "bi.float_center_adapt" - }], - - tabler: { - isNeedFreeze: false,//是否需要冻结单元格 - freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为tree时生效 - - isNeedMerge: true,//是否需要合并单元格 - - mergeRule: function (row1, row2) { //合并规则, 默认相等时合并 - return BI.isEqual(row1, row2); - }, - - columnSize: [], - rowSize: 37, - header: [], - items: [], - - //交叉表头 - crossHeader: [], - crossItems: [] - } - }) - }, - _init: function () { - BI.Tabler.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.pager = BI.createWidget(o.pager, { - type: "bi.pager" - }); - var creater = BI.createWidget({ - type: "bi.button_tree", - items: [{ - el: this.pager - }], - layouts: o.layouts - }) - this.pager.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - self.fireEvent(BI.Tabler.EVENT_CHANGE); - } - }); - this.container = BI.createWidget({ - type: "bi.layout" - }) - BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - el: this.container - }, { - el: creater, - height: 40 - }] - }); - this.populate(); - }, - - getCurrentPage: function () { - return this.pager.getValue(); - }, - - populate: function (opt) { - var o = this.options; - this.container.empty(); - - BI.extend(o.tabler, opt); - this.table = BI.createWidget(this.options.tabler, { - type: "bi.table_tree", - element: this.container - }); - } -}); -BI.Tabler.EVENT_CHANGE = "EVENT_CHANGE"; -$.shortcut("bi.tabler", BI.Tabler); \ No newline at end of file diff --git a/src/case/tip/tip.tooltip.js b/src/case/tip/tip.tooltip.js index 6746ce544..f0b43d114 100644 --- a/src/case/tip/tip.tooltip.js +++ b/src/case/tip/tip.tooltip.js @@ -27,29 +27,55 @@ BI.Tooltip = BI.inherit(BI.Tip, { e.stopEvent(); return false; }; - this.element.bind({"click": fn, "mousedown": fn, "mouseup": fn, "mouseover": fn, "mouseenter": fn, "mouseleave": fn, "mousemove": fn}); - - this.text = BI.createWidget({ - type: "bi.label", - element: this, - textAlign: "left", - whiteSpace: "normal", - text: o.text, - textHeight: 20, - hgap: this._const.hgap + this.element.bind({ + "click": fn, + "mousedown": fn, + "mouseup": fn, + "mouseover": fn, + "mouseenter": fn, + "mouseleave": fn, + "mousemove": fn }); + + var texts = (o.text + "").split("\n"); + if (texts.length > 1) { + BI.createWidget({ + type: "bi.vertical", + element: this, + hgap: this._const.hgap, + items: BI.map(texts, function (i, text) { + return { + type: "bi.label", + textAlign: "left", + whiteSpace: "normal", + text: text, + textHeight: 16 + } + }) + }) + } else { + this.text = BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "normal", + text: o.text, + textHeight: 20, + hgap: this._const.hgap + }); + } }, - setWidth: function(width){ + setWidth: function (width) { this.element.width(width - 2 * this._const.hgap); }, setText: function (text) { - this.text.setText(text); + this.text && this.text.setText(text); }, setLevel: function (level) { - this.element.removeClass("tooltip-success").removeClass("tooltip-warning"); + this.element.removeClass("tooltip-success").removeClass("tooltip-warning"); this.element.addClass("tooltip-" + level); } }); diff --git a/src/case/trigger/trigger.text.js b/src/case/trigger/trigger.text.js index d8a1a9857..d9747d36f 100644 --- a/src/case/trigger/trigger.text.js +++ b/src/case/trigger/trigger.text.js @@ -56,10 +56,12 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { setValue: function (value) { this.text.setValue(value); + this.text.setTitle(value); }, setText: function (text) { this.text.setText(text); + this.text.setTitle(text); } }); $.shortcut("bi.text_trigger", BI.TextTrigger); \ No newline at end of file diff --git a/src/case/trigger/trigger.text.select.js b/src/case/trigger/trigger.text.select.js index 5eec3ac3e..c266abe77 100644 --- a/src/case/trigger/trigger.text.select.js +++ b/src/case/trigger/trigger.text.select.js @@ -34,7 +34,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { var result = []; var items = BI.Tree.transformToArrayFormat(this.options.items); BI.each(items, function (i, item) { - if (BI.deepContains(vals, item.value)) { + if (BI.deepContains(vals, item.value) && !result.contains(item.text || item.value)) { result.push(item.text || item.value); } }); diff --git a/src/case/trigger/trigger.text.select.small.js b/src/case/trigger/trigger.text.select.small.js index dc38eda39..e4e23a998 100644 --- a/src/case/trigger/trigger.text.select.small.js +++ b/src/case/trigger/trigger.text.select.small.js @@ -33,7 +33,7 @@ BI.SmallSelectTextTrigger = BI.inherit(BI.Trigger, { var result = []; var items = BI.Tree.transformToArrayFormat(this.options.items); BI.each(items, function (i, item) { - if (BI.deepContains(vals, item.value)) { + if (BI.deepContains(vals, item.value) && !result.contains(item.text || item.value)) { result.push(item.text || item.value); } }); diff --git a/src/case/zclip/zclip.js b/src/case/zclip/zclip.js index caf4fdb1b..ee4b724f2 100644 --- a/src/case/zclip/zclip.js +++ b/src/case/zclip/zclip.js @@ -19,7 +19,7 @@ BI.ZeroClip = BI.inherit(BI.BasicButton, { FR.$defaultImport('/com/fr/bi/web/js/third/jquery.zclip.js', 'js'); BI.nextTick(function () { self.element.zclip({ - path: "resources/ZeroClipboard.swf", + path: FR.servletURL + "?op=resource&resource=/com/fr/bi/web/resources/ZeroClipboard.swf", copy: o.copy, beforeCopy: o.beforeCopy, afterCopy: o.afterCopy