etms/asset/js/cetc54/ui.dictCombox.js
liyuchen c24bea2687 Initial commit: JCDP 教育培训管理系统 v54
- 系统管理模块(用户/角色/组织/权限/日志)
- 教育培训计划管理模块
- 教育培训实施模块
- 考试管理模块
- 调研问卷管理模块
- 外派培训管理模块
- 年度培训总结模块
- 学习资源管理模块
- 任职资格管理模块
- 即时通讯模块
- APP 版本管理
- 统计分析模块(FineReport)
- 代码审查标准和报告(CODE_REVIEW_GUIDE.md, CODE_REVIEW_REPORT.md)
- 项目开发指南(PROJECT_GUIDE.md)
2026-04-16 16:41:34 +08:00

101 lines
2.8 KiB
JavaScript

/**
* Created by jinxs on 14-8-19.
*/
(function ($) {
/**
* 缓存名称
* @type {string}
* @private
*/
var _cacheName = 'uiDictCombobox';
/**
* @class 数据字典下拉框
* @extends uiCombo
* @requires {@link uiCombo}
* @constructor uiCombobox
* @summary 构造函数
* @param [options] {Object|String} 组件配置参数|要调用的组件方法名
* @param [param] {Object} 表示要调用的组件方法的参数
* @example
* // 构件组件
* $('#selectAge').dictCombobox({direction: 'left'});
* // 调用组件方法options
* $('#selectAge').dictCombobox("options");
*/
$.fn.dictCombobox = function (options, param) {
if (typeof options == 'string') {
var method = $.fn.dictCombobox.methods[options];
if (method) {
return method(this, param);
}else
{
return $(this).uiCombobox(options,param);
}
}
return this.each(function () {
var me = $(this);
var state = me.data(_cacheName);
options = options || {};
if (state) {
$.extend(state.options, options);
} else {
state = {
options: $.extend({}, $.fn.dictCombobox.defaults, me.parseUIConfig(), options),
data: []
};
me.data(_cacheName, state);
}
_init(me);
});
};
/**
* 方法
* @lends uiCombobox.prototype
*/
$.fn.dictCombobox.methods = $.fn.uiCombobox.defaults;
$.fn.dictCombobox.defaults = $.extend({}, $.fn.uiCombobox.defaults,
/**
* 默认配置
* @lends uiCombobox.prototype
*/
{
/**
* @type String
* @default "value"
* @summary 组件数据"值"字段
*/
valueField: 'value',
/**
* @type String
* @default "text"
* @summary 组件数据"文本"字段
*/
textField: 'name',
/**
* 字典key
*/
dictKey: '',
/**
* 是否缓存数据
*/
cache: true
});
var _init = function (target) {
var state = $.data(target[0], _cacheName);
var opts = state.options;
var hdName = dict_prefix + opts.dictKey;
if (window[hdName] && opts.cache) {
opts.mode = 'local';
opts.data = window[hdName];
} else {
opts.url = 'remote';
opts.url = dictBaseUrl + opts.dictKey;
opts.onLoadSuccess = function (data) {
window[hdName]=data;
}
}
target.uiCombobox(opts);
}
})(jQuery);