WdataPicker Calendar Control

1. Display across infinite level frames

 

No matter where you put the date control , you don't need to worry about being blocked by the outer iframe and affecting the customer experience , because the My97 date control can be displayed across infinite frames

 

Example 2-7 Cross-Infinite Frame Demonstration

It can span the frame iframe infinitely , no matter how nested the frame is, you don't have to worry about it , even if there is a scroll bar

 

2. Republic of China calendar and other special calendars

 

When the year format is set to yyy format , the year offset attribute yearOffset (the default value is 1911 , the first year of the Republic of China ) can be used to realize the calendar of the Republic of China and other special calendars .

Example 2-8 Demonstration of the Year of the Republic of China


<input type="text" id="d28" onClick="WdatePicker({dateFmt:'yyy/MM/dd'})"/>

Note : When the year format is set to yyy , the real date will be subtracted by a difference Quantity yearOffset ( default value : 1911), if it is the year of the Republic of China, the default value can be used without additional configuration , if it is other offset , it can be configured in the form of parameters

 

3. Bring convenience to programming

If the value of el is this, it can be omitted , that is, all el:this can be omitted. When the date box is set to disabled , it is forbidden to change the date ( the selection box will not pop up
). If the onpicked event
is not defined , the onchange
event of the text box is automatically triggered. The oncleared event is not defined , when it is cleared , the onchange event is automatically triggered

 

4. Other properties

Set the readOnly property to specify whether the date box is read-only
. Set the highLineWeekDay property to
specify whether to highlight weekends
. Set the isShowOthers property to
specify whether to display the dates of other months.
Add class="Wdate" and a date icon will appear on the right side of the selection box.

 

 

Multilingual and custom skins

1. Multi-language support

Through the lang attribute , you can configure the language for each date control separately , of course, you can also configure the global language list and language installation instructions through WdatePicker.js . For details, please refer to the language configuration

Example 3-1 Multilingual example

繁体中文:
<input id="d311" class="Wdate" type="text" onFocus="WdatePicker({lang:'zh-tw'})"/>

英文:
<input id="d312" class="Wdate" type="text" onFocus="WdatePicker({lang:'en'})"/>

简体中文:
<input id="d313" class="Wdate" type="text" onFocus="WdatePicker({lang:'zh-cn'})"/>


注意:默认情况lang='auto',即根据浏览器的语言自动选择语言.

 

2. 自定义和动态切换皮肤

通过skin属性,可以为每个日期控件单独配置皮肤,当然也可以通过WdatePicker.js配置全局的皮肤
皮肤列表和皮肤安装说明详见皮肤配置

 

示例3-2 皮肤演示

默认皮肤default: skin:'default'

<input id="d321" class="Wdate" type="text" onfocus="WdatePicker()"/>


注意:WdatePicker里配置了skin='default',所以此处可省略,同理,如果你把WdatePicker里的skin配置成'whyGreen'那么在不指定皮肤的情况下都使用'whyGreen'皮肤了

 


whyGreen皮肤: skin:'whyGreen'

<input id="d322" class="Wdate" type="text" onfocus="WdatePicker({skin:'whyGreen'})"/>

 

 

4. 日期范围限制

1. 静态限制
注意:日期格式必须与 realDateFmt realTimeFmt 一致

你可以给通过配置minDate(最小日期),maxDate(最大日期)为静态日期值,来限定日期的范围

示例4-1-1 限制日期的范围是 2006-09-10到2008-12-20
<input id="d411" class="Wdate" type="text" onfocus="WdatePicker({skin:'whyGreen',minDate:'2006-09-10',maxDate:'2008-12-20'})"/>

 

示例4-1-2 限制日期的范围是 2008-3-8 11:30:00 到 2008-3-10 20:59:30
<input type="text" class="Wdate" id="d412" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'2008-03-08 11:30:00',maxDate:'2008-03-10 20:59:30'})" value="2008-03-09 11:00:00"/>

 

示例4-1-3 限制日期的范围是 2008年2月 到 2008年10月
<input type="text" class="Wdate" id="d413" onfocus="WdatePicker({dateFmt:'yyyyM',minDate:'2008-2',maxDate:'2008-10'})"/>

 

示例4-1-4 限制日期的范围是 8:00:00 到 11:30:00
<input type="text" class="Wdate" id="d414" onfocus="WdatePicker({dateFmt:'H:mm:ss',minDate:'8:00:00',maxDate:'11:30:00'})"/>

 

2. 动态限制
注意:日期格式必须与 realDateFmt realTimeFmt 一致

你可以通过系统给出的动态变量,%y(当前年),%M(当前月)等来限度日期范围,

还可以通过#{}进行表达式运算,:#{%d+1}:表示明天

动态变量表

格式

说明

%y

当前年

%M

当前月

%d

当前日

%ld

本月最后一天

%H

当前时

%m

当前分

%s

当前秒

#{}

运算表达式,:#{%d+1}:表示明天

#F{}

{}之间是函数可写自定义JS代码

 

示例4-2-1 只能选择今天以前的日期(包括今天)
<input id="d421" class="Wdate" type="text" onfocus="WdatePicker({skin:'whyGreen',maxDate:'%y-%M-%d'})"/>

 

示例4-2-2 使用了运算表达式只能选择今天以后的日期(不包括今天)
<input id="d422" class="Wdate" type="text" onfocus="WdatePicker({minDate:'%y-%M-#{%d+1}'})"/>

 

示例4-2-3 只能选择本月的日期1号至本月最后一天
<input id="d423" class="Wdate" type="text" onfocus="WdatePicker({minDate:'%y-%M-01',maxDate:'%y-%M-%ld'})"/>

 

示例4-2-4 只能选择今天7:00:00至明天21:00:00的日期
<input id="d424" class="Wdate" type="text" onfocus="WdatePicker({dateFmt:'yyyy-M-d H:mm:ss',minDate:'%y-%M-%d 7:00:00',maxDate:'%y-%M-#{%d+1} 21:00:00'})"/>

 

示例4-2-5 使用了运算表达式只能选择 20小时前至 30小时后的日


<input id="d425" class="Wdate" type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',minDate:'%y-%M-%d #{%H-20}:%m:%s',maxDate:'%y-%M-%d #{%H+30}:%m:%s'})"/>

 

3 . 脚本自定义限制
注意:日期格式必须与 realDateFmt realTimeFmt 一致

 

系统提供了$dp.$D$dp.$DV这两个API来辅助你进行日期运算,此外你还可以通过在 #F{} 中填入你自定义的脚本,做任何你想做的日期限制

 

示例4-3-1 前面的日期不能大于后面的日期且两个日期都不能大于 2020-10-01

合同有效期从
<input id="d4311" class="Wdate" type="text" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'d4312\')||\'2020-10-01\'}'})"/>

<input id="d4312" class="Wdate" type="text" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d4311\')}',maxDate:'2020-10-01'})"/>

注意:
两个日期的日期格式必须相同


$dp.$ 相当于 document.getElementById 函数.
那么为什么里面的 ' 使用 \' ? 那是因为 " ' 都被外围的函数使用了,故使用转义符 \ ,否则会提示JS语法错误
.
所以您在其他地方使用时注意把 \' 改成 " 或者 ' 来使用
.

#F{$dp.$D(\'d4312\')||\'2020-10-01\'} 表示当 d4312 为空时, 采用 2020-10-01 的值作为最大值

 

示例4-3-2 前面的日期+3天 不能大于 后面的日期

日期从
<input type="text" class="Wdate" id="d4321"

onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'d4322\',{d:-3});}'})"/>
<input type="text" class="Wdate" id="d4322"

onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d4321\',{d:3});}'})"/>

使用 $dp.$D 函数可以将日期框中的值,加上定义的日期差量:
两个参数: id={字符类型}需要处理的文本框的id , obj={对象类型}
日期差量

日期差量用法:
属性y,M,d,H,m,s分别代表年月日时分秒

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326991250&siteId=291194637