mirror of https://github.com/layui/layui
parent
3812997373
commit
a061579f29
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
@ -18,12 +16,31 @@ body{padding: 50px 100px;}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
日期时间范围选择:
|
范围选择1:
|
||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
<input type="text" class="layui-input" id="test1">
|
<input type="text" class="layui-input" id="test1">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br><br><hr><br>
|
<br><hr>
|
||||||
|
|
||||||
|
<div class="layui-form">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label">范围选择2</label>
|
||||||
|
<div class="layui-inline" id="test1-2">
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" autocomplete="off" id="test-startDate-1" class="layui-input" placeholder="开始日期">
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-mid">-</div>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" autocomplete="off" id="test-endDate-1" class="layui-input" placeholder="结束日期">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br><hr>
|
||||||
|
|
||||||
日期选择器:
|
日期选择器:
|
||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
|
@ -118,7 +135,7 @@ layui.use('laydate', function(laydate){
|
||||||
//trigger: 'focus'
|
//trigger: 'focus'
|
||||||
})
|
})
|
||||||
|
|
||||||
//双控件
|
//范围选择1
|
||||||
laydate.render({
|
laydate.render({
|
||||||
elem: '#test1' //指定元素
|
elem: '#test1' //指定元素
|
||||||
,type: 'datetime'
|
,type: 'datetime'
|
||||||
|
@ -142,6 +159,16 @@ layui.use('laydate', function(laydate){
|
||||||
|
|
||||||
//return;
|
//return;
|
||||||
|
|
||||||
|
//范围选择2
|
||||||
|
laydate.render({
|
||||||
|
elem: '#test1-2'
|
||||||
|
,type: 'date'
|
||||||
|
,range: ['#test-startDate-1', '#test-endDate-1']
|
||||||
|
//,value: ['2022-05-01', '2022-06-01']
|
||||||
|
//,value: '2022-05-01 - 2022-06-01'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
//单控件
|
//单控件
|
||||||
laydate.render({
|
laydate.render({
|
||||||
elem: '#test2'
|
elem: '#test2'
|
||||||
|
|
|
@ -23,7 +23,7 @@ var config = {
|
||||||
,{pkg: pkg, js: ';'}
|
,{pkg: pkg, js: ';'}
|
||||||
]
|
]
|
||||||
//模块
|
//模块
|
||||||
,modules: 'lay,laytpl,laypage,laydate,jquery,layer,util,dropdown,slider,colorpicker,element,upload,form,table,tree,transfer,carousel,rate,flow,code'
|
,modules: 'lay,laytpl,laypage,laydate,jquery,layer,util,dropdown,slider,colorpicker,element,upload,form,table,tree,transfer,carousel,rate,flow,layedit,code'
|
||||||
};
|
};
|
||||||
|
|
||||||
//获取参数
|
//获取参数
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "layui",
|
"name": "layui",
|
||||||
"realname": "layui",
|
"realname": "layui",
|
||||||
"version": "2.6.9",
|
"version": "2.6.10",
|
||||||
"description": "Classic modular Front-End UI library",
|
"description": "Classic modular Front-End UI library",
|
||||||
"main": "dist/layui.js",
|
"main": "dist/layui.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
,Layui = function(){
|
,Layui = function(){
|
||||||
this.v = '2.6.9'; // layui 版本号
|
this.v = '2.6.10'; // layui 版本号
|
||||||
}
|
}
|
||||||
|
|
||||||
//识别预先可能定义的指定全局对象
|
//识别预先可能定义的指定全局对象
|
||||||
|
|
|
@ -91,14 +91,16 @@
|
||||||
|
|
||||||
|
|
||||||
//数字前置补零
|
//数字前置补零
|
||||||
lay.digit = function(num, length, end){
|
lay.digit = function(num, length){
|
||||||
|
if(!(typeof num === 'string' || typeof num === 'number')) return '';
|
||||||
|
|
||||||
var str = '';
|
var str = '';
|
||||||
num = String(num);
|
num = String(num);
|
||||||
length = length || 2;
|
length = length || 2;
|
||||||
for(var i = num.length; i < length; i++){
|
for(var i = num.length; i < length; i++){
|
||||||
str += '0';
|
str += '0';
|
||||||
}
|
}
|
||||||
return num < Math.pow(10, length) ? str + (num|0) : num;
|
return num < Math.pow(10, length) ? str + num : num;
|
||||||
};
|
};
|
||||||
|
|
||||||
//创建元素
|
//创建元素
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
/** layDate 日期与时间控件 | MIT Licensed */
|
/** layDate 日期与时间控件 | MIT Licensed */
|
||||||
|
|
||||||
;!function(window, document){
|
;!function(window, document){
|
||||||
|
@ -189,7 +188,9 @@
|
||||||
if(!options.elem[0]) return;
|
if(!options.elem[0]) return;
|
||||||
|
|
||||||
//日期范围分隔符
|
//日期范围分隔符
|
||||||
that.rangeStr = options.range ? (typeof options.range === 'string' ? options.range : '-') : '';
|
that.rangeStr = options.range ? (
|
||||||
|
typeof options.range === 'string' ? options.range : '-'
|
||||||
|
) : '';
|
||||||
|
|
||||||
//若 range 参数为数组,则表示为开始日期和结束日期的 input 对象
|
//若 range 参数为数组,则表示为开始日期和结束日期的 input 对象
|
||||||
if(layui.type(options.range) === 'array'){
|
if(layui.type(options.range) === 'array'){
|
||||||
|
@ -240,7 +241,7 @@
|
||||||
) +'$');
|
) +'$');
|
||||||
that.EXP_SPLIT = new RegExp('^'+ that.EXP_SPLIT +'$', '');
|
that.EXP_SPLIT = new RegExp('^'+ that.EXP_SPLIT +'$', '');
|
||||||
|
|
||||||
//如果不是input|textarea元素,则默认采用click事件
|
//如果不是 input|textarea 元素,则默认采用 click 事件
|
||||||
if(!that.isInput(options.elem[0])){
|
if(!that.isInput(options.elem[0])){
|
||||||
if(options.trigger === 'focus'){
|
if(options.trigger === 'focus'){
|
||||||
options.trigger = 'click';
|
options.trigger = 'click';
|
||||||
|
@ -593,11 +594,14 @@
|
||||||
//如果传入了开始和结束日期的 input 对象,则将其拼接为日期范围字符
|
//如果传入了开始和结束日期的 input 对象,则将其拼接为日期范围字符
|
||||||
if(that.rangeElem){
|
if(that.rangeElem){
|
||||||
var vals = [that.rangeElem[0].val(), that.rangeElem[1].val()];
|
var vals = [that.rangeElem[0].val(), that.rangeElem[1].val()];
|
||||||
|
|
||||||
if(vals[0] && vals[1]){
|
if(vals[0] && vals[1]){
|
||||||
return vals.join(' ' + that.rangeStr + ' ');
|
return vals.join(' ' + that.rangeStr + ' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return that.isInput(elem) ? elem.value : (options.position === 'static' ? '' : lay(elem).attr('lay-date'));
|
return that.isInput(elem)
|
||||||
|
? elem.value
|
||||||
|
: (options.position === 'static' ? '' : lay(elem).attr('lay-date'));
|
||||||
}()
|
}()
|
||||||
|
|
||||||
//校验日期有效数字
|
//校验日期有效数字
|
||||||
|
@ -703,7 +707,7 @@
|
||||||
) + lang.formatError[1]);
|
) + lang.formatError[1]);
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
} else if(value && layui.type(value) === 'date'){ //如果值为日期对象时
|
} else if(value && layui.type(value) === 'date'){ //若值为日期对象
|
||||||
options.dateTime = that.systemDate(value);
|
options.dateTime = that.systemDate(value);
|
||||||
} else {
|
} else {
|
||||||
//重置开始日期
|
//重置开始日期
|
||||||
|
@ -1189,7 +1193,11 @@
|
||||||
,options = that.config
|
,options = that.config
|
||||||
,dateTime = date || (state == 'end'
|
,dateTime = date || (state == 'end'
|
||||||
? lay.extend({}, that.endDate, that.endTime)
|
? lay.extend({}, that.endDate, that.endTime)
|
||||||
: (options.range ? lay.extend({}, options.dateTime, that.startTime) : options.dateTime))
|
: (
|
||||||
|
options.range
|
||||||
|
? lay.extend({}, options.dateTime, that.startTime)
|
||||||
|
: options.dateTime)
|
||||||
|
)
|
||||||
,format = laydate.parse(dateTime, that.format, 1);
|
,format = laydate.parse(dateTime, that.format, 1);
|
||||||
|
|
||||||
//返回日期范围字符
|
//返回日期范围字符
|
||||||
|
@ -1229,9 +1237,13 @@
|
||||||
lay(elem).val(value);
|
lay(elem).val(value);
|
||||||
} else {
|
} else {
|
||||||
//如果 range 传入了开始和结束的 input 对象,则分别对其赋值
|
//如果 range 传入了开始和结束的 input 对象,则分别对其赋值
|
||||||
if(that.rangeElem){
|
var rangeElem = that.rangeElem;
|
||||||
that.rangeElem[0].val(value ? that.parse('start') : '');
|
if(rangeElem){
|
||||||
that.rangeElem[1].val(value ? that.parse('end') : '');
|
if(layui.type(value) !== 'array'){
|
||||||
|
value = value.split(' '+ that.rangeStr +' ');
|
||||||
|
}
|
||||||
|
rangeElem[0].val(value[0] || '');
|
||||||
|
rangeElem[1].val(value[1] || '');
|
||||||
} else {
|
} else {
|
||||||
if(lay(elem).find('*').length === 0){
|
if(lay(elem).find('*').length === 0){
|
||||||
lay(elem).html(value);
|
lay(elem).html(value);
|
||||||
|
|
|
@ -179,7 +179,7 @@ layui.define('jquery', function(exports){
|
||||||
}
|
}
|
||||||
|
|
||||||
//还原转义的 html
|
//还原转义的 html
|
||||||
,unescape: function(str){
|
,unescape: function(html){
|
||||||
if(html === undefined || html === null) html = '';
|
if(html === undefined || html === null) html = '';
|
||||||
html += '';
|
html += '';
|
||||||
return html.replace(/\&/g, '&')
|
return html.replace(/\&/g, '&')
|
||||||
|
|
Loading…
Reference in New Issue