FineUI

Namespace

FineUI

Description:
  • FineUI命名空间

Classes

Accordion
AccordionPane
Base
Button
ButtonGroup
Calendar
CheckBox
CheckBoxList
Component
Container
DataList
DatePicker
DropDownBox
DropDownList
Field
FileUpload
Form
Grid
GridColumn
GroupPanel
Hidden
HtmlEditor
HyperLink
Image
Label
LinkButton
Menu
MenuCheckBox
MenuItem
MenuItemBase
MenuSeparator
MessageBox
NumberBox
PagingToolbar
Panel
PanelBase
RadioButton
RadioButtonList
Tab
TabStrip
TextArea
TextBox
TimePicker
Tool
Toolbar
ToolbarFill
ToolbarItemBase
ToolbarSeparator
ToolbarText
Tree
TriggerBox
ViewPort
Window

Members

(static) KEY

Description:
  • 键盘按键代码

键盘按键代码

Methods

(static) addCSS(id, content, isCSSFile)

Description:
  • 向页面添加CSS内容或者引用CSS文件

Parameters:
Name Type Description
id string

键(防止重复添加相同的内容)

content string

CSS内容或者CSS文件网址

isCSSFile boolean

是否CSS文件

(static) addCommas(string) → {string}

Description:
  • 添加千分位分隔符

Parameters:
Name Type Description
string string

数字

Returns:

包含千分位分隔符的字符串

Type
string

(static) addDotSeparator(string, dotSeparator, commaSeparator) → {string}

Description:
  • 添加小数分隔符

Parameters:
Name Type Description
string string

数字

dotSeparator string

小数分隔符

commaSeparator string

千分位分隔符(如果为undefined,则不添加千分位分隔符)

Returns:

包含小数分隔符的字符串

Type
string

(static) addJS(id, content, isJSFile)

Description:
  • 向页面添加JS内容或者引用JS文件

Parameters:
Name Type Description
id string

键(防止重复添加相同的内容)

content string

JS内容或者JS文件网址

isJSFile boolean

是否JS文件

(static) addMainTab(tabstripInstance, options)

Description:
  • 添加选项卡

Parameters:
Name Type Description
tabstripInstance FineUI.TabStrip

选项卡面板实例

options Object

选项卡参数

Properties
Name Type Default Description
id string ''

选项卡标识符

iframeUrl string ''

选项卡中内联框架的地址(默认启用iframe)

title string ''

选项卡标题

icon string ''

选项卡标题图标

iconFont string ''

选项卡标题图标字体

refreshWhenExist boolean true

如果选项卡已存在,是否更新选项卡并刷新内联框架(默认值:true)

moveToEnd boolean true

将新增选项卡移到尾部(如果选项卡已存在,则不改变位置)(默认值:true)

actived boolean true

是否激活选项卡(默认值:true)

(static) addMainTabByHref(tabstripInstance, treeInstance, href, activedopt, moveToEndopt)

Description:
  • 添加选项卡(在树中查找拥有href的树节点)

Parameters:
Name Type Attributes Default Description
tabstripInstance FineUI.TabStrip

选项卡面板实例

treeInstance FineUI.Tree

树控件实例

href string

树节点的超链接网址

actived boolean <optional>
true

是否激活选项卡(默认为true)

moveToEnd boolean <optional>
true

将新增选项卡移到尾部(如果选项卡已存在,则不改变位置)(默认为true)

(static) alert(options)

Description:
  • 弹出提示对话框

Parameters:
Name Type Description
options Object

初始参数

Properties
Name Type Default Description
target string '_self'

显示对话框的目标位置(可选项为:_self, _parent, _top)

message string ''

消息正文

title string ''

标题文本(留空则使用默认标题)

messageIcon string 'information'

消息图标(可选项为:information, warning, question, error, success)

closable boolean true

是否可关闭

ok function

点击确认按钮时执行的回调函数

(static) beforeAjaxError(callback)

Description:
  • 注册AJAX回发失败回调函数(返回false则不执行默认的错误处理)

Example

自定义错误提示框

FineUI.beforeAjaxError(function (data) {
	FineUI.alert('服务器返回错误!');
	return false;
});
Parameters:
Name Type Description
callback function

AJAX回发失败时执行的回调函数

(static) beforeAjaxSuccess(callback)

Description:
  • 注册AJAX回发成功回调函数(返回false则不执行AJAX响应脚本)

Example

页面跳转前弹出系统确认对话框

FineUI.beforeAjaxSuccess(function (data) {
	// 通过返回的字符串,判断是否即将执行页面跳转
	if (data.indexOf('window.location.href=') === 0) {
		if (!window.confirm('是否执行页面跳转?')) {
			return false; // 继续留在当前页面
		}
	}
});
Parameters:
Name Type Description
callback function

AJAX回发成功时执行的回调函数

(static) beforePostBack(listener) → {function}

Description:
  • 注册 FineUIJava 普通控件服务端事件发起回发前的监听器。

    本函数只用于补充或替换事件名后面的业务参数。客户端事件名由框架固定,监听器不能指定后台方法; 客户端 listeners 明确返回 false 时,回发会在进入本钩子前取消。

Example
var removeListener = F.beforePostBack(function(targetId, eventType, options) {
    if (targetId === 'btnSave' && eventType === 'click') {
        return { source: 'toolbar' };
    }
});

// 页面不再需要监听时调用
removeListener();
Parameters:
Name Type Description
listener F_beforePostBack_listener

回发前监听器

Returns:

注销当前监听器的函数

Type
function

(static) confirm(options)

Description:
  • 弹出确认对话框

Parameters:
Name Type Description
options Object

初始参数

Properties
Name Type Default Description
target string '_self'

显示对话框的目标位置(可选项为:_self, _parent, _top)

message string ''

消息正文

title string ''

标题文本(留空则使用默认标题)

messageIcon string 'question'

消息图标(可选项为:information, warning, question, error, success)

closable boolean true

是否可关闭

ok function

点击确认按钮时执行的回调函数

cancel function

点击取消按钮时执行的回调函数

(static) cookie(key, value, options)

Description:
  • 新增或者修改Cookie

Parameters:
Name Type Description
key string

value string

options Object

参数

Properties
Name Type Default Description
path string '/'

Cookie保存的网站路径(默认为网站根目录)

expires number

过期时间(单位:天;留空则为会话Cookie,浏览器关闭时自动过期)

(static) customEvent(eventName, eventArgumentsopt)

Description:
  • 触发页面级自定义回发事件(适用于 FineUIPro、FineUICore RazorForms 开发模式与 FineUIJava)。 服务端由 Page_CustomEvent 接收;数组和普通对象自动序列化,0 与 false 会作为明确参数保留。

    等价于 FineUI.doPostBack({ eventName: 事件名, eventArgument: 参数 })。需要用到完整选项时改用 FineUI.doPostBack——FineUIPro 可用 enableAjax、loading 与 success / error / complete,FineUICore 可用 params / fields / complete 等,FineUIJava 中只有 complete 生效。

Example
F.customEvent('Grid1_RowCommand', { rowId: '102', operation: 'delete' });
Parameters:
Name Type Attributes Description
eventName string

非空自定义事件名,不能包含 $

eventArguments string | number | boolean | Object | Array <optional>

可选事件参数

(static) doPostBack(options)

Description:
  • 自定义回发请求

    注:

    • FineUIPro、FineUICore RazorForms 与 FineUIJava 均支持 eventName / eventArgument 页面级自定义回发,后台由 Page_CustomEvent 接收。
    • 在 FineUICore 与 FineUIPro 中,本函数要求后台的返回数据是一段可执行的 JavaScript 代码(不能是 JSON 字符串!)。
    • FineUIPro 使用自身的 WebForms 提交机制,支持 eventName / eventArgument / enableAjax、loading 与 success / error / complete; 不支持 Core 特有的 url / fields / params / disableControl。
    • FineUIJava 提供本函数的兼容实现,但只支持 eventName / eventArgument / eventTarget / complete 四个选项: 回发响应是纯 JSON(不含可执行脚本),其余选项(url / fields / params / success / error / disableControl / enableAjaxLoading / ajaxLoadingType / ajaxLoadingText / ajaxLoadingMaskText / showAjaxLoadingMaskText)均不生效; eventTarget 非空时只同步控件状态、不触发后台事件。FineUIJava 的普通控件事件由框架根据标签声明自动发起, 请求提交到当前页面 URL,只携带控件标识和客户端事件名;后台方法名只保留在服务端事件映射中。 在 FineUIJava 中触发页面级自定义回发,推荐直接用 FineUI.customEvent

    参考示例:

    参考文档:

Examples
function getPressedInfo(btngroup) {
	var result = {
		id: btngroup.id,
		pressed: []
	};
	$.each(btngroup.items, function (index, btn) {
		if (btn.isPressed()) {
			result.pressed.push(btn.getText());
		}
	});
	return FineUI.toJSON(result);
}

FineUI.doPostBack({
	url: '/Button/ButtonGroupPress/ButtonGroup_PressChanged',
	params: {
		pressedInfo: getPressedInfo(FineUI.ui.ButtonGroup3)
	}
});
FineUI.doPostBack({
	url: '/Other/FormAjaxComplete/onForm1Submit',
	fields: 'Form1',
	params: {
		key1: 'value1',
		key2: {
			'sub1': 'sub-value1',
			'sub2': 'sub-value2'
		}
	},
	enableAjaxLoading: false, // 不显示回发请求动画
	complete: function (data) {
		// 回发请求结束回调函数
	}
});

eventName 与 eventArgument 的合成规则按 eventTarget 分两支;非空 eventTarget 的手工控件回发只适用于 FineUICore RazorForms:

// eventTarget 留空 —— 页面级自定义回发,由后台 Page_CustomEvent 接收。
// 参数会被 URL 编码(后台会解码一次),所以参数里带 $ 也不会被误当分隔符。
// 下面两种写法等价,F.customEvent 就是这个用法的简化形式:
FineUI.doPostBack({
	eventName: 'GetCheckedNodes',
	eventArgument: { rowId: '102', operation: 'delete' }
});

F.customEvent('GetCheckedNodes', { rowId: '102', operation: 'delete' });


// eventTarget 非空 —— FineUICore RazorForms 手工触发普通控件后台事件。
// Pro、Core RazorForms 与 Java 的框架自动回发都使用同一线格式:第一段是 F.js 客户端事件名,
// 后面才是业务参数;但 Pro 的 F.doPostBack 始终回发 PageManager,Java 的普通控件事件也不向
// 公开 F.doPostBack 暴露入口,因此这两个产品的业务代码不要照抄下面写法。
// 参数原样拼接、不编码,因此可以带多段(如 '102$0')。
// 注意两点:① 还要用 url 指定后台的事件处理方法名,否则后台找不到方法;
//          ② 各段内不能出现 $ —— 本支不编码,后台按 $ 原样分段,多出来的 $ 会让参数错位。
//             参数可能含 $ 时请留空 eventTarget 走自定义回发,那一支会编码。
// 下面两种写法等价:
FineUI.doPostBack({
	url: 'Grid1_RowClick',
	eventTarget: 'Grid1',
	eventName: 'rowclick',
	eventArgument: '102$0'
});

FineUI.doPostBack({
	url: 'Grid1_RowClick',
	eventTarget: 'Grid1',
	eventArgument: 'rowclick$102$0'   // 不给 eventName 时,eventArgument 就是已合成的完整参数串
});
Parameters:
Name Type Description
options Object

请求参数

Properties
Name Type Description
url string

发送请求的地址(FineUICore)

fields string

发送到服务器的表单字段数据,以逗号分隔多个表单字段(如果是容器,则查找容器内的所有表单字段)

params Object

发送到服务器的数据

complete F_doPostBack_callback

回发请求完成的回调函数

success F_doPostBack_callback

回发请求成功的回调函数

error F_doPostBack_callback

回发请求失败的回调函数

disableControl string

回发之前禁用的控件(防止用户快速提交)

enableAjaxLoading boolean

启用回发提示

ajaxLoadingType string

回发提示的类型(可选项为:default, mask)

ajaxLoadingText string

回发提示的显示文本

ajaxLoadingMaskText string

回发提示的显示文本(ajaxLoadingType=mask)

showAjaxLoadingMaskText string

是否显示回发提示文本(ajaxLoadingType=mask)

eventTarget string

触发本次回发的控件标识符(FineUICore RazorForms);页面级自定义回发留空。Pro / Core / Java 框架自动生成的普通控件事件都会把 F.js 客户端事件名放在 eventArgument 第一段。FineUIJava 传入非空值时只同步状态,业务代码不能借此触发普通控件事件

eventName string

页面级自定义事件名(FineUIPro、FineUICore RazorForms、FineUIJava)。框架自动合成 eventArgument,无需自己拼 "事件名$参数"

eventArgument string | number | boolean | Object | Array

业务参数;数组和普通对象自动 JSON 序列化,0 与 false 会保留

(static) endsWith(value, source) → {boolean}

Description:
  • 判断一个字符串是否以某个字符串结束

Parameters:
Name Type Description
value string

字符串

source string

源字符串

Returns:

如果是则返回true,否则返回false

Type
boolean

(static) formatDate(value, format) → {Date}

Description:
  • 将日期对象转换为字符串

Example
日期格式规则请参考:FineUI.parseDate
Parameters:
Name Type Description
value Date

日期对象

format string

日期格式化字符串(标准的C#格式化字符串,比如:'yyyy-MM-dd')

Returns:

日期字符串

Type
Date

(static) formatNumber(number, format, trimZeroopt) → {string}

Description:
  • 将数字格式化为字符串

Example
// 标准格式(小数位固定,不足补零)
FineUI.formatNumber(12345.6789, 'N2');    // "12,345.68"
FineUI.formatNumber(12345.6789, 'F2');    // "12345.68"
FineUI.formatNumber(0.1234, 'P2');        // "12.34%"
FineUI.formatNumber(12345.6789, 'E2');    // "1.23E+4"
FineUI.formatNumber(123, 'D5');           // "00123"

// 尾零省略(第三个参数传入 true)
FineUI.formatNumber(8500,    'N2', true);   // "8,500"    (原本 "8,500.00",尾零省略)
FineUI.formatNumber(8500.1,  'N2', true);   // "8,500.1"  (原本 "8,500.10",尾零省略)
FineUI.formatNumber(8500.75, 'N2', true);   // "8,500.75" (无尾零,保持不变)
FineUI.formatNumber(5,       'F2', true);   // "5"        (原本 "5.00",尾零省略)
FineUI.formatNumber(0.5,     'P2', true);   // "50%"      (原本 "50.00%",尾零省略)
FineUI.formatNumber(0.123,   'P2', true);   // "12.3%"    (原本 "12.30%",尾零省略)
FineUI.formatNumber(10000,   'E2', true);   // "1E+4"     (原本 "1.00E+4",尾零省略)
FineUI.formatNumber(15000,   'E2', true);   // "1.5E+4"   (原本 "1.50E+4",尾零省略)
Parameters:
Name Type Attributes Description
number number

要格式化的数字(整数或浮点数)

format string

数字格式字符串(C#风格,如 'N2'、'F2'、'P2'、'E2'、'D5')

trimZero string | boolean <optional>

是否去除尾零(可选,传入 true 或 'true')。 当启用时,对标准格式(N/F/P/E)的结果自动去除小数尾部多余的零。 例如:formatNumber(8500, 'N2', true) → "8,500"(而非 "8,500.00")

千分位格式(Number Format)

  • 'N' : 千分位格式,默认2位小数 (例: 12345.6789 → "12,345.68")
  • 'N0' : 千分位格式,无小数位 (例: 12345.6789 → "12,346") - 四舍五入到整数
  • 'N2' : 千分位格式,2位小数 (例: 12345.6789 → "12,345.68")

定点数格式(Fixed-point Format)

  • 'F' : 定点数格式,默认2位小数 (例: 12345.6789 → "12345.68")
  • 'F0' : 定点数格式,无小数位 (例: 12345.6789 → "12346") - 四舍五入到整数
  • 'F2' : 定点数格式,2位小数 (例: 12345.6789 → "12345.68")

百分比格式(Percent Format)

  • 'P' : 百分比格式,默认2位小数 (例: 0.1234 → "12.34%")
  • 'P0' : 百分比格式,无小数位 (例: 0.1234 → "12%") - 四舍五入到整数百分比
  • 'P2' : 百分比格式,2位小数 (例: 0.1234 → "12.34%")

科学计数法格式(Scientific Format)

  • 'E' : 科学计数法,默认6位小数 (例: 12345.6789 → "1.234568E+4")
  • 'E2' : 科学计数法,2位小数 (例: 12345.6789 → "1.23E+4")
  • 'E4' : 科学计数法,4位小数 (例: 12345.6789 → "1.2346E+4")

十进制整数格式(Decimal Integer Format)

  • 'D' : 十进制整数格式,默认不填充 (例: 12345.6789 → "12345") - 截断小数部分
  • 'D5' : 十进制整数格式,填充到5位 (例: 123 → "00123")
  • 'D8' : 十进制整数格式,填充到8位 (例: 12345 → "00012345")

尾零省略(第三个参数 trimZero)

在标准格式字符串的基础上,传入第三个参数 true,自动去除结果中小数部分的尾部零。 例如:formatNumber(8500, 'N2', true)"8,500"(而非 "8,500.00"

在表格列中,对应 C# 属性 TrimZero="true",JS 写法 fieldFormat: 'N2', trimZero: true

Returns:

格式化后的字符串

Type
string

(static) formatString(form, …param)

Description:
  • 格式化字符串

Parameters:
Name Type Attributes Description
form string

需要格式化的字符串

param string <repeatable>

参数,对应格式字符串中的 {0}, {1}, {2}...

(static) getActiveWindow() → {FineUI.Window}

Description:
  • 获取当前激活的窗体对象

Returns:

窗体对象(其 window 属性表示窗体所在的页面)

Type
FineUI.Window

(static) getHidden(fieldId) → {string}

Description:
  • 获取隐藏字段的值(

Parameters:
Name Type Description
fieldId string

节点ID

Returns:

隐藏字段的值

Type
string

(static) getType(typeName) → {object}

Description:
  • 获取类型字符串对应的类型(例如从字符串 'tabstrip' 获取类型 FineUI.TabStrip)

Parameters:
Name Type Description
typeName string

类型字符串

Returns:

类型

Type
object

(static) hasHScrollbar(el) → {boolean}

Description:
  • 是否存在水平滚动条

Parameters:
Name Type Description
el jQuery

节点

Returns:

是否存在水平滚动条

Type
boolean

(static) hasVScrollbar(el) → {boolean}

Description:
  • 是否存在垂直滚动条

Parameters:
Name Type Description
el jQuery

节点

Returns:

是否存在水平滚动条

Type
boolean

(static) htmlDecode(value) → {string}

Description:
  • HTML解码

Parameters:
Name Type Description
value string

输入值

Returns:

解码后的值

Type
string

(static) htmlEncode(value) → {string}

Description:
  • HTML编码

Parameters:
Name Type Description
value string

输入值

Returns:

编码后的值

Type
string

(static) initTreeTabStrip(treeMenu, mainTabStrip, options)

Description:
  • 初始化官网示例框架(左侧树与右侧选项卡面板交互)

Example
FineUI.initTreeTabStrip(FineUI.ui.Tree1, FineUI.ui.TabStrip1, {
    maxTabCount: 10,
    maxTabMessage: '请先关闭一些选项卡(最多允许打开 10 个)!'
});
Parameters:
Name Type Description
treeMenu FineUI.Tree

左侧树实例

mainTabStrip FineUI.TabStrip

选项卡面板实例

options Object

可选参数

Properties
Name Type Default Description
updateHash boolean true

切换Tab时,是否更新地址栏Hash值(默认值:true)

refreshWhenExist boolean true

如果选项卡已存在,是否更新选项卡并刷新内联框架(默认值:true)

refreshWhenTabChange boolean false

切换选项卡时,是否刷新内部IFrame

maxTabCount number

最大允许打开的选项卡数量

maxTabMessage string

超过最大允许打开选项卡数量时的提示信息

beforeNodeClick F_initTreeTabStrip_beforeNodeClick

节点点击事件之前执行(返回false则不执行点击事件)

beforeTabAdd F_initTreeTabStrip_beforeTabAdd

添加选项卡之前执行(返回false则不添加选项卡)

singleTabId string

单标签页模式下的标签页标识符(留空即为多标签页模式)

moveToEnd boolean true

将新增选项卡移到尾部(如果选项卡已存在,则不改变位置)(默认为true)

compactHash boolean false

应用部署在子路径时,Hash 是否省略 F.baseUrl;读取时自动补回以恢复内嵌页面

(static) isARR(value) → {boolean}

Description:
  • 测试对象是否为数组

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isBOO(value) → {boolean}

Description:
  • 测试对象是否为布尔型

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isDAT(value) → {boolean}

Description:
  • 测试对象是否为日期对象

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isELE(value) → {boolean}

Description:
  • 测试对象是否为DOM节点元素

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isEMP(value) → {boolean}

Description:
  • 测试对象是否为空(undefined, null 或者 空字符串)

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isEOBJ(value) → {boolean}

Description:
  • 测试对象是否为空对象(不包含任何属性)

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isFUN(value) → {boolean}

Description:
  • 测试对象是否为函数

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isNAN(value) → {boolean}

Description:
  • 测试对象是否为NaN

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isNUM(value) → {boolean}

Description:
  • 测试对象是否为数字

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isPOBJ(value) → {boolean}

Description:
  • 测试对象是否为纯粹对象(通过 {} 或者 new Object 创建的对象)

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isSTR(value) → {boolean}

Description:
  • 测试对象是否为字符串

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isUND(value) → {boolean}

Description:
  • 测试对象是否为undefined或者null

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) noAnimation(fn)

Description:
  • 回调函数中不进行动画操作

Parameters:
Name Type Description
fn function

回调函数

(static) noConflict()

Description:
  • 释放window.F命名空间,以便其他脚本可以使用它

(static) noEvent(fn)

Description:
  • 回调函数中不触发事件

Parameters:
Name Type Description
fn function

回调函数

(static) noLayout(fn)

Description:
  • 回调函数中不进行布局操作

Parameters:
Name Type Description
fn function

回调函数

(static) noValidate(fn)

Description:
  • 回调函数中不验证表单字段

Parameters:
Name Type Description
fn function

回调函数

(static) notify(options)

Description:
  • 弹出通知对话框

Parameters:
Name Type Description
options Object

初始参数

Properties
Name Type Default Description
target string '_self'

显示对话框的目标位置(可选项为:_self, _parent, _top)

message string ''

消息正文

title string ''

标题文本(留空则使用默认标题)

messageIcon string 'question'

消息图标(可选项为:information, warning, question, error, success)

closable boolean true

是否可关闭

hide function

对话框隐藏时执行的回调函数

modal boolean false

是否为模式对话框

draggable boolean true

是否可拖动

header boolean true

是否显示标题栏

showLoading boolean false

是否显示正在加载图标

positionX string 'right'

横坐标的位置(可选项为:left, center, right)

positionY string 'bottom'

纵坐标的位置(可选项为:top, center, bottom)

displayMilliseconds number 0

自动消失之前显示的秒数(0-不消失)

displayProgress boolean true

是否显示倒计时进度条(仅在 displayMilliseconds > 0 时生效;可通过 F.init({messageBoxDisplayProgress: false}) 全局关闭)

(static) parseDate(value, format) → {Date}

Description:
  • 将字符串转换为日期对象

Examples
// 基本日期解析
FineUI.parseDate('2023-12-25', 'yyyy-MM-dd');        
// 返回: 2023年12月25日

FineUI.parseDate('25/12/2023', 'dd/MM/yyyy');        
// 返回: 2023年12月25日

FineUI.parseDate('Dec 25, 2023', 'MMM dd, yyyy');    
// 返回: 2023年12月25日
// 日期时间解析
FineUI.parseDate('2023-12-25 14:30:45', 'yyyy-MM-dd HH:mm:ss');
// 返回: 2023年12月25日 14:30:45

FineUI.parseDate('12/25/2023 02:30', 'MM/dd/yyyy hh:mm');
// 返回: 2023年12月25日 14:30:00

FineUI.parseDate('December 25, 2023', 'MMMM dd, yyyy');
// 返回: 2023年12月25日
// 短格式和缩写格式
FineUI.parseDate('23-12-25', 'yy-M-d');              
// 返回: 2023年12月25日

FineUI.parseDate('12/25/23', 'M/d/yy');              
// 返回: 2023年12月25日
// 时间格式解析
FineUI.parseDate('14:30', 'HH:mm');                  
// 返回: 今天14:30:00

FineUI.parseDate('14:30:45', 'H:m:s');               
// 返回: 今天14:30:45
Parameters:
Name Type Description
value string

要解析的日期字符串

format string

日期格式化字符串,用于指定输入字符串的格式(比如:'yyyy-MM-dd')

日期部分

  • d - 月中的某一天,一位数的日期没有前导零 (1-31)
  • dd - 月中的某一天,一位数的日期有一个前导零 (01-31)
  • ddd - 周中某天的缩写名称 (Mon, Tue, Wed等)
  • dddd - 周中某天的完整名称 (Monday, Tuesday, Wednesday等)

月份部分

  • M - 月份数字,一位数的月份没有前导零 (1-12)
  • MM - 月份数字,一位数的月份有一个前导零 (01-12)
  • MMM - 月份的缩写名称 (Jan, Feb, Mar等)
  • MMMM - 月份的完整名称 (January, February, March等)

年份部分

  • yy - 不包含纪元的年份,两位数字 (00-99)
  • yyyy - 包括纪元的四位数的年份 (0001-9999)

时间部分

  • h - 12小时制的小时,一位数的小时数没有前导零 (1-12)
  • hh - 12小时制的小时,一位数的小时数有前导零 (01-12)
  • H - 24小时制的小时,一位数的小时数没有前导零 (0-23)
  • HH - 24小时制的小时,一位数的小时数有前导零 (00-23)
  • m - 分钟,一位数的分钟数没有前导零 (0-59)
  • mm - 分钟,一位数的分钟数有一个前导零 (00-59)
  • s - 秒,一位数的秒数没有前导零 (0-59)
  • ss - 秒,一位数的秒数有一个前导零 (00-59)
Returns:

解析后的日期对象

Type
Date

(static) parseJSON(value) → {Object}

Description:
  • 将JSON字符串转换为JavaScript对象

Parameters:
Name Type Description
value string

JSON字符串

Returns:

JavaScript对象

Type
Object

(static) progressHtml(value, options)

Description:
  • 生成进度条HTML片段

Parameters:
Name Type Description
value Object

初始值

options Object

初始参数

Properties
Name Type Default Description
height number

进度条的高度

textVisible boolean false

是否显示进度条文本

textInside boolean false

是否将进度条文本显示在进度条内部

(static) prompt(options)

Description:
  • 弹出输入对话框

Parameters:
Name Type Description
options Object

初始参数

Properties
Name Type Default Description
target string '_self'

显示对话框的目标位置(可选项为:_self, _parent, _top)

message string ''

消息正文

title string ''

标题文本(留空则使用默认标题)

messageIcon string 'question'

消息图标(可选项为:information, warning, question, error, success)

closable boolean true

是否可关闭

ok function

点击确认按钮时执行的回调函数(回调函数的第一个参数为用户输入值)

cancel function

点击取消按钮时执行的回调函数(回调函数的第一个参数为用户输入值)

multiLine boolean false

是否显示多行输入框

multiLineHeight number

多行输入框的高度

defaultValue string ''

输入框的缺省值

required boolean false

输入框是否为必填项

(static) queryString(name, urlopt) → {string}

Description:
  • 获取URL中的参数值

Parameters:
Name Type Attributes Description
name string

参数名

url string <optional>

在指定URL中查找(留空在当前页面URL中查找)

Returns:

URL中参数名对应的值

Type
string

(static) rateEvents(container, callback)

Description:
  • 注册评分事件

Parameters:
Name Type Description
container jQuery

评分容器

callback F_rateEvents_callback

评分改变的回调函数

(static) rateHtml(value, options)

Description:
  • 生成评分HTML片段

Parameters:
Name Type Description
value Object

初始值

options Object

初始参数

Properties
Name Type Default Description
allowClear boolean true

是否允许通过点击来清除评分

allowHalf boolean false

是否允许半星评分

iconFont string ''

评分图标字体

iconFontCls string ''

自定义评分图标字体的样式类

character string ''

自定义评分字符(比如用字母'A'代替默认的五角星图标)

count number 5

评分图标的个数

readonly boolean false

是否只读

textVisible boolean false

是否显示评分文本

textRenderer function | string

自定义评分文本的渲染函数,也可以填全局函数的名字(服务端下发时只能是名字)

(static) rawHtml(value, …param) → {object}

Description:
  • 声明一段“可信 HTML”。控件的文本类属性(如 text、title、tooltip 等)默认会做 HTML 转义(防 XSS), 当你确信某段 HTML 可信、需要原样输出(不转义)时,用它包裹后赋给对应属性即可。 详见文档:安全策略(用 RawHtml / F.rawHtml 安全输出 HTML)

Example
// 用法1:创建控件时,把带 HTML 的文本声明为可信,原样输出(不转义)
F.create({ type: 'Button', text: F.rawHtml('<i class="f-icon f-iconfont f-iconfont-add"></i> 新增') });

// 用法2:运行时调用控件方法更新文本,同样用 F.rawHtml 包裹
F.ui.label1.setText(F.rawHtml('<b>已保存</b>'));

// 用法3:菜单项、面板标题等文本类属性通用
F.create({ type: 'MenuItem', text: F.rawHtml('<span class="hot">热门</span> 推荐') });

// 特例:表格列渲染函数 renderer 的返回值本就原样输出(不转义),故【无需】用 F.rawHtml 包裹,
// 直接返回 HTML 字符串即可;因为不转义,其中若含用户数据务必先自行 F.htmlEncode
F.create({ type: 'Grid', columns: [{
    field: 'status',
    renderer: function (value) { return '<span class="tag">' + F.htmlEncode(value) + '</span>'; }
}] });

// 用法5:模板 + 用户数据——先对用户数据 HTML 编码,再用 {0}、{1} 占位放进可信 HTML(防 XSS)
F.rawHtml('<b>{0}</b>:{1}', F.htmlEncode(userName), F.htmlEncode(userInput));

// 反例:不要把用户输入直接包成可信 HTML(会导致 XSS)
// F.create({ type: 'Label', text: F.rawHtml(userInput) });  // ❌ 危险
Parameters:
Name Type Attributes Description
value string

可信的 HTML 字符串;作为格式字符串时对应 {0}, {1}, {2}...

param string <repeatable>

可选的格式化参数

Returns:

可信 HTML 包装对象

Type
object

(static) ready(callback)

Description:
  • 注册页面渲染完毕回调函数

Parameters:
Name Type Description
callback function

页面加载完毕时执行的回调函数

(static) removeCommas(string) → {string}

Description:
  • 移除千分位分隔符

Parameters:
Name Type Description
string string

数字

Returns:

不包含千分位分隔符的字符串

Type
string

(static) removeCookie(key, options)

Description:
  • 删除Cookie

Parameters:
Name Type Description
key string

options Object

参数

Properties
Name Type Default Description
path string '/'

Cookie保存的网站路径(默认为网站根目录)

(static) removeDotSeparator(string, dotSeparator, commaSeparator) → {string}

Description:
  • 移除小数分隔符

Parameters:
Name Type Description
string string

数字

dotSeparator string

小数分隔符

commaSeparator string

千分位分隔符(如果为undefined,则表示输入的数字不包含千分位分隔符)

Returns:

不包含小数分隔符的字符串

Type
string

(static) removeHidden(fieldId)

Description:
  • 删除隐藏字段(

Parameters:
Name Type Description
fieldId string

节点ID

(static) reset(containerId)

Description:
  • 重置容器内的全部表单字段

Parameters:
Name Type Description
containerId string

容器标识符(留空则重置页面上的全部表单字段)

(static) resolveUrl(url) → {string}

Description:
  • 将「相对 Web 根/子应用根」的路径解析为客户端可用的完整 URL。 内部基于 FineUI.baseUrl 拼接,调用者无需关心 baseUrl 是否以 / 结尾,也无需关心页面部署在站点根还是子目录。 绝对 URL(http(s):// 、协议相对 // 、data:、blob: 等)原样返回;否则去掉前导的 ~ 和 / 后拼到 baseUrl 之后。

Parameters:
Name Type Description
url string

相对路径(推荐 /res/xxx 形式;~/res/xxx 或 res/xxx 结果相同)或绝对 URL

Returns:

客户端可用的完整 URL

Type
string

(static) setHidden(fieldId, fieldValue)

Description:
  • 设置隐藏字段的值(

Parameters:
Name Type Description
fieldId string

节点ID

fieldValue string

设置的值

(static) smartLayout(fn)

Description:
  • 回调函数执行完毕后再进行布局操作

Parameters:
Name Type Description
fn function

回调函数

(static) startsWith(value, source) → {boolean}

Description:
  • 判断一个字符串是否以某个字符串开头

Parameters:
Name Type Description
value string

字符串

source string

源字符串

Returns:

如果是则返回true,否则返回false

Type
boolean

(static) toJSON(value) → {string}

Description:
  • 将JavaScript对象转换为JSON字符串

Parameters:
Name Type Description
value Object

JavaScript对象

Returns:

JSON字符串

Type
string

(static) ui(options) → {FineUI.Component}

Description:
  • 创建控件实例

Parameters:
Name Type Description
options object

初始参数

Returns:

控件实例

Type
FineUI.Component

(static) urlDecode(url) → {string}

Description:
  • URL解码

Parameters:
Name Type Description
url string

输入值

Returns:

解码后的值

Type
string

(static) urlEncode(url) → {string}

Description:
  • URL编码

Parameters:
Name Type Description
url string

输入值

Returns:

编码后的值

Type
string

(static) validateForm(formId, optionsopt) → {boolean}

Description:
Example

验证一个表单:

if (FineUI.validateForm('form1')) {
	FineUI.alert('表单验证通过');
}
Parameters:
Name Type Attributes Description
formId string

需要验证的表单标识符

options Object <optional>

可选参数

Properties
Name Type Default Description
target string '_self'

验证失败时提示对话框的弹出位置(可选项为:_self, _parent, _top)

messageBox boolean true

验证失败时是否弹出提示对话框

messageBoxPlain boolean false

提示对话框是否使用简洁按钮样式

Returns:

是否验证通过

Type
boolean

(static) validateForms(formIds, optionsopt) → {boolean}

Description:
  • 验证多个表单,验证失败时弹出提示对话框并把焦点定位到第一个非法字段。

    大多数场景不需要手工调用:按钮、工具图标、菜单项、链接按钮都有 validateForm / validateForms 属性,点击时会自动验证、不通过就不再执行后续逻辑 (见 FineUI.Button)。本方法用于没有控件可挂的场景,例如自定义回发前的手工校验。

Examples

验证两个表单,失败时用简洁样式的提示框:

if (FineUI.validateForms(['form1', 'form2'], { messageBoxPlain: true })) {
	// 全部通过后才做的事
}

提示框弹到顶层窗口(本页处于 IFrame 中时常用):

FineUI.validateForms(['form1'], { target: '_top' });

只想拿验证结果、不弹提示框:

if (!FineUI.validateForms(['form1'], { messageBox: false })) {
	// 自行处理
}
Parameters:
Name Type Attributes Description
formIds Array.<string>

需要验证的表单标识符数组

options Object <optional>

可选参数

Properties
Name Type Default Description
target string '_self'

验证失败时提示对话框的弹出位置(可选项为:_self, _parent, _top)

messageBox boolean true

验证失败时是否弹出提示对话框

messageBoxPlain boolean false

提示对话框是否使用简洁按钮样式

Returns:

是否全部验证通过

Type
boolean

(static) windowResize(fn)

Description:
  • 注册页面大小改变事件(延迟 500 毫秒触发)

Parameters:
Name Type Description
fn function

回调函数