Authored by weiqingting

tijiao

... ... @@ -37,8 +37,8 @@ module.exports={
namespace:"common",
apis:{
login:function(req,callback){
var user = req.body.user||'wxtest1';
var password = req.body.password||'yoho9646abcdef';
var user = req.body.user;
var password = req.body.password;
var userInfo = {},result={code:400,message:"登录失败"};
//调用登陆
console.log(Iaccount.login);
... ...
<template>
<div class="datepicker-days vue-show-imo">
<table class=" table-condensed">
<thead>
<tr>
<th class="prev" @click="prev">
<i class="fa fa-chevron-left fi-arrow-left"></i>
</th>
<th colspan="5" class="date-switch" @click="tomonth">{{month}} {{year}}</th>
<th class="next" @click="next">
<i class="fa fa-chevron-right fi-arrow-right"></i>
</th>
</tr>
<tr>
<th class="dow" v-for="week in weeks">{{week}}</th>
</tr>
</thead>
<tbody>
<tr v-for="week in calendar">
<td :class="{today: day.date.toDateString() === new Date().toDateString(), selected: day.day === this.currentDay, not: ! day.day || day.day === 32}" v-for="day in week" track-by="$index" v-text="day.day === 32 ? '' : day.day" @click="selectDate(day)"></td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
export default {
props:["dateTime","mo"],
data(){
return {
// date: new Date(this.dateText),
weeks: ['日', '一', '二', '三', '四', '五', '六'],
months:['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'],
currentDay: ""
}
},
computed: {
month() {
return this.months[this.dateTime.month]
},
year() {
return this.dateTime.year
},
calendar() {
let result = []
let calendar = []
let date = this.dateTime
let year = this.year
let month = this.month
let first = new Date(date.year, date.month, 1).getDay()
let days = new Date(date.year, date.month + 1, 0).getDate()
for (let i = 0; i < days; i++, first++) {
calendar[first] = i + 1
}
calendar = calendar.filter((v) => v)
// 切割
first -= days
result[0] = []
let currentDay = first
for (let i = 0; i < 7 - currentDay; i++, first++) {
result[0][first] = {
day: i + 1,
date: new Date(`${year}/${month}/${i + 1}`)
}
}
while(currentDay > -1) {
result[0][currentDay - 1] = {
day: 32,
date: new Date(`${year}/${month}/32`)
}
currentDay--
}
let count = Math.ceil((days - (7 - first)) / 7)
let lastDay = result[0].slice(-1)[0].day
for (let i = 1; i <= count; i++) {
result[i] = []
for (let ii = 0; ii < 7; ii++) {
result[i][ii] = {
day: calendar[lastDay + ii],
date: new Date(`${year}/${month}/${calendar[lastDay + ii]}`)
}
}
lastDay += 7
}
//console.dir(result)
return result
}
},
methods: {
prev() {
this.currentDay = ""
this.dateTime.month-=1
},
next() {
this.currentDay = ""
this.dateTime.month+=1
},
selectDate(value) {
if (! value.day || value.day === 32) {
return
}
this.dateTime.date=value.day
this.mo=''
},
tomonth(){
this.mo="month"
}
},
ready() {
this.currentDay = this.dateTime.date
}
}
</script>
\ No newline at end of file
... ...
<template>
<div class="datepicker-months vue-show-imo">
<table class=" table-condensed">
<thead>
<tr>
<th class="prev" @click="prev">
<i class="fa fa-chevron-left fi-arrow-left"></i>
</th>
<th colspan="5" class="date-switch">{{year}}</th>
<th class="next" @click="next">
<i class="fa fa-chevron-right fi-arrow-right"></i>
</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="7" >
<span class="month" v-for="month in months" v-text="month" @click="selectMonth(month)"></span>
</td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
export default {
props:["dateTime","mo"],
data(){
return {
months:['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
}
},
computed:{
year() {
return this.dateTime.year
}
},
methods:{
prev() {
this.currentMonth = ""
this.dateTime.year-=1;
},
next() {
this.currentMonth = ""
this.dateTime.year+=1
},
selectMonth(value){
this.dateTime.month=+value-1
this.mo=''
}
},
ready() {
this.currentMonth = this.dateTime.month
}
}
</script>
\ No newline at end of file
... ...
<template>
<div class="datepicker-days vue-show-imo">
<table class=" table-condensed">
<thead>
<tr>
<th class="prev" @click="prev">
<i class="fa fa-chevron-left fi-arrow-left"></i>
</th>
<th colspan="5" class="date-switch" @click="tomonth">{{month}} {{year}}</th>
<th class="next" @click="next">
<i class="fa fa-chevron-right fi-arrow-right"></i>
</th>
</tr>
<tr>
<th class="dow" v-for="week in weeks">{{week}}</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="7">
<span class="hour">1:00</span>
</td>
</tr>
</tbody>
</table>
</div>
</template>
\ No newline at end of file
... ...
... ... @@ -21,368 +21,96 @@
}
</style>
<template>
<input type="text" @click="showCalendar" v-model="value" placeholder="{{placeholder}}" class="form-control">
<div @click.stop="" @touchstart.stop="" class="datepicker datepicker-dropdown dropdown-menu vue-show" v-show="show" :style="{'left':x+'px','top':y+'px'}" transition="calendar" transition-mode="out-in">
<div class="datepicker-days vue-show-imo">
<table class=" table-condensed">
<thead>
<tr>
<th class="prev">
<i class="fa fa-chevron-left fi-arrow-left" @click="prev"></i>
</th>
<th colspan="5" class="date-switch">
<input type="number" v-model="year" value="{{year}}" @change="render(year,month)" min="1970" max="2100" maxlength="4" number>
/
{{month+1}}
</th>
<th class="next">
<i class="fa fa-chevron-right fi-arrow-right" @click="next"></i>
</th>
</tr>
<tr>
<td v-for="week in weeks" class="week">{{week}}</td>
</tr>
</thead>
<tr v-for="(k1,day) in days">
<td
v-for="(k2,child) in day"
:class="{'today':child.today,'disabled':child.disabled}"
@click="select(k1,k2,$event)" @touchstart="select(k1,k2,$event)">
{{child.day}}
<div class="lunar" v-if="showLunar">{{child.lunar}}</div>
</td>
</tr>
</table>
<div class="calendar-time" v-show="type=='datetime'||type=='time'">
<div class="timer">
<input type="number" v-model="hour" value="{{hour}}" min="0" max="23" maxlength="2" number>
<input type="number" v-model="minute" value="{{minute}}" min="0" max="59" maxlength="2" number>
<input type="number" v-model="second" value="{{second}}" min="0" max="59" maxlength="2" number>
</div>
</div>
<div class="calendar-button" v-show="type=='datetime'||type=='time'||range">
<button @click="ok">确定</button>
<button @click="cancel" class="cancel">取消</button>
</div>
</div>
<input type="text" class="form-control" @click="showCalendar" :value="date">
<div class="datepicker datepicker-dropdown dropdown-menu vue-show" :style="{'left':x+'px','top':y+'px'}" v-show="isshow">
<date-days :date-time.sync="dateTime" :mo.sync="mo" v-show="mo==='day'"></date-days>
<date-months :date-time.sync="dateTime" :mo.sync="mo" v-show="mo==='month'"></date-months>
</div>
</template>
<script>
module.exports = {
props: {
show: {
type: Boolean,
twoWay: true,
default:false
},
type: {
type: String,
default:"date"
},
value: {
type: String,
twoWay: true,
default:""
},
placeholder: {
type: String,
default:"请输入日期"
import dateDays from "./dateDays.vue"
import dateMonths from "./dateMonths.vue"
export default {
props:{
value:{
type:String
},
x: {
type: Number,
default:0
},
y: {
type: Number,
default:0
},
begin: {
type: String,
default:""
},
end: {
type: String,
default:""
},
range: {
type: Boolean,
default:false
},
rangeBegin:{
type: Array,
default:Array
},
rangeEnd:{
type: Array,
default:Array
format:{
type:String,
default:"yyyy-MM-dd"
}
},
data:function(){
return {
year:0,
month:0,
day:0,
hour:0,
minute:0,
second:0,
days:[],
today:[],
currentMonth:Number,
sep:"/",
weeks:['日', '一', '二', '三', '四', '五', '六'],
months:['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
}
components:{
dateDays,
dateMonths
},
created:function(){
var that=this;
var now = new Date();
if(that.value!=""){
if(that.value.indexOf("-")!=-1)that.sep="-";
if(that.value.indexOf(".")!=-1)that.sep=".";
data() {
return {
// dateText: this.value?new Date(this.value):new Date(),
if(that.type=="date"){
var split=that.value.split(that.sep);
that.year = parseInt(split[0]);
that.month =parseInt(split[1])-1;
that.day = parseInt(split[2]);
}else if(that.type=="datetime"){
var split=that.value.split(" ");
var splitDate=split[0].split(that.sep);
that.year = parseInt(splitDate[0]);
that.month =parseInt(splitDate[1])-1;
that.day = parseInt(splitDate[2]);
if(split.length>1){
var splitTime=split[1].split(":");
that.hour = splitTime[0];
that.minute = splitTime[1];
that.second = splitTime[2];
}
}
if(that.range){
var split=that.value.split(" ~ ");
if(split.length>1){
var beginSplit=split[0].split(that.sep);
var endSplit=split[1].split(that.sep);
that.rangeBegin=[parseInt(beginSplit[0]),parseInt(beginSplit[1]-1),parseInt(beginSplit[2])];
that.rangeEnd=[parseInt(endSplit[0]),parseInt(endSplit[1]-1),parseInt(endSplit[2])];
}
}
}else{
that.year = now.getFullYear();
that.month =now.getMonth();
that.day = now.getDate();
that.hour = that.zero(now.getHours());
that.minute = that.zero(now.getMinutes());
that.second = that.zero(now.getSeconds());
if(that.range){
that.rangeBegin=Array;
that.rangeEnd=Array;
}
}
that.render(that.year,that.month);
dateTime:{
year:'',
month:'',
date:'',
hour:'',
minute:'',
second:''
},
watch:{
year:function(val,old){
console.log("new %s old %s time:%s",val,old,+new Date);
}
},
methods:{
zero:function(n){
return n<10?'0'+n:n;
},
render:function(y,m){
var that=this;
var firstDayOfMonth = new Date(y, m, 1).getDay();//当月第一天
var lastDateOfMonth = new Date(y, m + 1, 0).getDate();//当月最后一天
var lastDayOfLastMonth = new Date(y, m, 0).getDate();//最后一月的最后一天
that.year=y;
that.currentMonth=that.months[m];
var seletSplit=that.value.split(" ")[0].split(that.sep);
var i,line=0,temp=[];
for(i=1;i <= lastDateOfMonth;i++) {
var dow = new Date(y, m, i).getDay();
// 第一行
if (dow == 0) {
temp[line]=[];
}else if (i == 1) {
temp[line]=[];
var k = lastDayOfLastMonth - firstDayOfMonth + 1;
for (var j = 0; j < firstDayOfMonth; j++) {
temp[line].push({day:k,disabled:true});
k++;
}
}
// 如果是日期范围
if(that.range){
var options={day:i};
if(that.rangeBegin.length>0){
var beginTime=Number(new Date(that.rangeBegin[0],that.rangeBegin[1],that.rangeBegin[2]));
var endTime=Number(new Date(that.rangeEnd[0],that.rangeEnd[1],that.rangeEnd[2]));
var thisTime=Number(new Date(that.year,that.month,i));
if(beginTime<=thisTime&&endTime>=thisTime){
options.today=true;
}
}
temp[line].push(options);
}else{
var chk = new Date();
var chkY = chk.getFullYear();
var chkM = chk.getMonth();
if(
parseInt(seletSplit[0])==that.year
&&
parseInt(seletSplit[1])-1==that.month
&&
parseInt(seletSplit[2])==i
&&
(that.begin==undefined||that.end==undefined)
){
temp[line].push({day:i,today:true});
that.today=[line,temp[line].length-1];
// 当天
}else if (chkY == that.year && chkM == that.month && i == that.day&&that.value==undefined) {
temp[line].push({day:i,today:true});
that.today=[line,temp[line].length-1];
} else {//默认
// 1.判断begin和end的日期
var options={day:i,today:false};
if(that.begin!=undefined){
var beginSplit=that.begin.split(that.sep);
var beginTime=Number(new Date(parseInt(beginSplit[0]),parseInt(beginSplit[1])-1,parseInt(beginSplit[2])));
var thisTime=Number(new Date(that.year,that.month,i));
if(beginTime>thisTime)options.disabled=true;
}
if(that.end!=undefined){
var endSplit=that.end.split(that.sep);
var endTime=Number(new Date(parseInt(endSplit[0]),parseInt(endSplit[1])-1,parseInt(endSplit[2])));
var thisTime=Number(new Date(that.year,that.month,i));
if(endTime<thisTime)options.disabled=true;
}
temp[line].push(options);
}
x: 0,
y: 0,
mo:'day',
show:false
}
// 最后一行
if (dow == 6) {
line++;
}else if (i == lastDateOfMonth) {
var k = 1;
for (dow; dow < 6; dow++) {
temp[line].push({day:k,disabled:true});
k++;
}
}
}//end for
that.days=temp;
},
prev:function(e){
e.stopPropagation();
var that=this;
if (that.month == 0) {
that.month = 11;
that.year = that.year - 1;
} else {
that.month = that.month - 1;
}
that.render(that.year,that.month);
computed:{
date(){
return this.showDate(this.dateTime,this.format);
},
next:function(e){
e.stopPropagation();
var that=this;
if (that.month == 11) {
that.month = 0;
that.year = that.year + 1;
} else {
that.month = that.month + 1;
isshow(){
return this.mo?true:false;
}
that.render(that.year,that.month);
},
select:function(k1,k2,e){
if(e!=undefined)e.stopPropagation();
var that=this;
// 日期范围
if(that.range){
if(that.rangeBegin.length==0||that.rangeEndTemp!=0){
that.rangeBegin=[that.year,that.month,that.days[k1][k2].day,that.hour,that.minute,that.second];
that.rangeBeginTemp=that.rangeBegin;
that.rangeEnd=[that.year,that.month,that.days[k1][k2].day,that.hour,that.minute,that.second];
that.rangeEndTemp=0;
}else{
that.rangeEnd=[that.year,that.month,that.days[k1][k2].day,that.hour,that.minute,that.second];
that.rangeEndTemp=1;
// 判断结束日期小于开始日期则自动颠倒过来
if(+new Date(that.rangeEnd[0],that.rangeEnd[1],that.rangeEnd[2])<+new Date(that.rangeBegin[0],that.rangeBegin[1],that.rangeBegin[2])){
that.rangeBegin=that.rangeEnd;
that.rangeEnd=that.rangeBeginTemp;
}
}
that.render(that.year,that.month);
}else{
// 取消上次选中
if(that.today.length>0){
that.days[that.today[0]][that.today[1]].today=false;
}
// 设置当前选中天
that.days[k1][k2].today=true;
that.day=that.days[k1][k2].day;
that.today=[k1,k2];
if(that.type=='date'){
that.value=that.year+that.sep+that.zero(that.month+1)+that.sep+that.zero(that.days[k1][k2].day);
that.show=false;
}
}
},
ok:function(){
methods:{
showCalendar(e){
var that=this;
if(that.range){
that.value=that.output(that.rangeBegin)+" ~ "+that.output(that.rangeEnd);
this.x=e.target.offsetLeft;
this.y=e.target.offsetTop+e.target.offsetHeight+0;
if(this.format.indexOf("dd")>-1){
this.mo="day";
}else{
that.value=that.output([that.year,that.month,that.day,that.hour,that.minute,that.second]);
this.mo="month";
}
that.show=false;
},
cancel:function(){
this.show=false;
},
// 格式化输出
output:function(args){
var that=this;
if(that.type=='time'){
return that.zero(args[3])+":"+that.zero(args[4])+":"+that.zero(args[5])
showDate(dateTime,format) {
var o = {
"M+": dateTime.month + 1, //month
"d+": dateTime.date, //day
"h+": dateTime.hour, //hour
"m+": dateTime.minute, //minute
"s+": dateTime.second
}
if(that.type=='datetime'){
return args[0]+that.sep+that.zero(args[1]+1)+that.sep+that.zero(args[2])+" "+that.zero(args[3])+":"+that.zero(args[4])+":"+that.zero(args[5])
}
if(that.type=='date'){
return args[0]+that.sep+that.zero(args[1]+1)+that.sep+that.zero(args[2]);
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
(dateTime.year + "").substr(4 - RegExp.$1.length));
for (var k in o) if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
return format;
}
},
showCalendar:function(e){
e.stopPropagation();
var that=this;
that.show=true;
that.x=e.target.offsetLeft;
that.y=e.target.offsetTop+e.target.offsetHeight+0;
var bindHide=function(e){
e.stopPropagation();
that.show=false;
document.removeEventListener('click',bindHide,false);
};
setTimeout(function(){
document.addEventListener('click',bindHide,false);
},500);
ready(){
this.mo="";
let dateTime=this.value?new Date(this.value):new Date();
this.dateTime={
year:dateTime.getFullYear(),
month:dateTime.getMonth(),
date:dateTime.getDate(),
hour:dateTime.getHours(),
minute:dateTime.getMinutes(),
second:dateTime.getSeconds()
}
}
}
}
</script>
\ No newline at end of file
... ...
<style>
.datepicker{
padding: 10px;
}
.datepicker.vue-show{
display:block;
}
.datepicker>div.vue-show-imo{
display:block;
}
.datepicker input[type='number']{
text-align: center;
}
.calendar-button{
float:right;
margin: 5px 5px 0;
}
.calendar-time{
text-align:center;
margin: 5px 0;
}
</style>
<template>
<input type="text" @click="showCalendar" v-model="value" placeholder="{{placeholder}}" class="form-control">
<div @click.stop="" @touchstart.stop="" class="datepicker datepicker-dropdown dropdown-menu vue-show" v-show="show" :style="{'left':x+'px','top':y+'px'}" transition="calendar" transition-mode="out-in">
<div class="datepicker-days vue-show-imo">
<table class=" table-condensed">
<thead>
<tr>
<th class="prev">
<i class="fa fa-chevron-left fi-arrow-left" @click="prev"></i>
</th>
<th colspan="5" class="date-switch">
<input type="number" v-model="year" value="{{year}}" @change="render(year,month)" min="1970" max="2100" maxlength="4" number>
/
{{month+1}}
</th>
<th class="next">
<i class="fa fa-chevron-right fi-arrow-right" @click="next"></i>
</th>
</tr>
<tr>
<td v-for="week in weeks" class="week">{{week}}</td>
</tr>
</thead>
<tr v-for="(k1,day) in days">
<td
v-for="(k2,child) in day"
:class="{'today':child.today,'disabled':child.disabled}"
@click="select(k1,k2,$event)" @touchstart="select(k1,k2,$event)">
{{child.day}}
<div class="lunar" v-if="showLunar">{{child.lunar}}</div>
</td>
</tr>
</table>
<div class="calendar-time" v-show="type=='datetime'||type=='time'">
<div class="timer">
<input type="number" v-model="hour" value="{{hour}}" min="0" max="23" maxlength="2" number>
<input type="number" v-model="minute" value="{{minute}}" min="0" max="59" maxlength="2" number>
<input type="number" v-model="second" value="{{second}}" min="0" max="59" maxlength="2" number>
</div>
</div>
<div class="calendar-button" v-show="type=='datetime'||type=='time'||range">
<button @click="ok">确定</button>
<button @click="cancel" class="cancel">取消</button>
</div>
</div>
</div>
</template>
<script>
module.exports = {
props: {
show: {
type: Boolean,
twoWay: true,
default:false
},
type: {
type: String,
default:"date"
},
value: {
type: String,
twoWay: true,
default:""
},
placeholder: {
type: String,
default:"请输入日期"
},
x: {
type: Number,
default:0
},
y: {
type: Number,
default:0
},
begin: {
type: String,
default:""
},
end: {
type: String,
default:""
},
range: {
type: Boolean,
default:false
},
rangeBegin:{
type: Array,
default:Array
},
rangeEnd:{
type: Array,
default:Array
}
},
data:function(){
return {
year:0,
month:0,
day:0,
hour:0,
minute:0,
second:0,
days:[],
today:[],
currentMonth:Number,
sep:"/",
weeks:['日', '一', '二', '三', '四', '五', '六'],
months:['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
}
},
created:function(){
var that=this;
var now = new Date();
if(that.value!=""){
if(that.value.indexOf("-")!=-1)that.sep="-";
if(that.value.indexOf(".")!=-1)that.sep=".";
if(that.type=="date"){
var split=that.value.split(that.sep);
that.year = parseInt(split[0]);
that.month =parseInt(split[1])-1;
that.day = parseInt(split[2]);
}else if(that.type=="datetime"){
var split=that.value.split(" ");
var splitDate=split[0].split(that.sep);
that.year = parseInt(splitDate[0]);
that.month =parseInt(splitDate[1])-1;
that.day = parseInt(splitDate[2]);
if(split.length>1){
var splitTime=split[1].split(":");
that.hour = splitTime[0];
that.minute = splitTime[1];
that.second = splitTime[2];
}
}
if(that.range){
var split=that.value.split(" ~ ");
if(split.length>1){
var beginSplit=split[0].split(that.sep);
var endSplit=split[1].split(that.sep);
that.rangeBegin=[parseInt(beginSplit[0]),parseInt(beginSplit[1]-1),parseInt(beginSplit[2])];
that.rangeEnd=[parseInt(endSplit[0]),parseInt(endSplit[1]-1),parseInt(endSplit[2])];
}
}
}else{
that.year = now.getFullYear();
that.month =now.getMonth();
that.day = now.getDate();
that.hour = that.zero(now.getHours());
that.minute = that.zero(now.getMinutes());
that.second = that.zero(now.getSeconds());
if(that.range){
that.rangeBegin=Array;
that.rangeEnd=Array;
}
}
that.render(that.year,that.month);
},
watch:{
year:function(val,old){
console.log("new %s old %s time:%s",val,old,+new Date);
}
},
methods:{
zero:function(n){
return n<10?'0'+n:n;
},
render:function(y,m){
var that=this;
var firstDayOfMonth = new Date(y, m, 1).getDay();//当月第一天
var lastDateOfMonth = new Date(y, m + 1, 0).getDate();//当月最后一天
var lastDayOfLastMonth = new Date(y, m, 0).getDate();//最后一月的最后一天
that.year=y;
that.currentMonth=that.months[m];
var seletSplit=that.value.split(" ")[0].split(that.sep);
var i,line=0,temp=[];
for(i=1;i <= lastDateOfMonth;i++) {
var dow = new Date(y, m, i).getDay();
// 第一行
if (dow == 0) {
temp[line]=[];
}else if (i == 1) {
temp[line]=[];
var k = lastDayOfLastMonth - firstDayOfMonth + 1;
for (var j = 0; j < firstDayOfMonth; j++) {
temp[line].push({day:k,disabled:true});
k++;
}
}
// 如果是日期范围
if(that.range){
var options={day:i};
if(that.rangeBegin.length>0){
var beginTime=Number(new Date(that.rangeBegin[0],that.rangeBegin[1],that.rangeBegin[2]));
var endTime=Number(new Date(that.rangeEnd[0],that.rangeEnd[1],that.rangeEnd[2]));
var thisTime=Number(new Date(that.year,that.month,i));
if(beginTime<=thisTime&&endTime>=thisTime){
options.today=true;
}
}
temp[line].push(options);
}else{
var chk = new Date();
var chkY = chk.getFullYear();
var chkM = chk.getMonth();
if(
parseInt(seletSplit[0])==that.year
&&
parseInt(seletSplit[1])-1==that.month
&&
parseInt(seletSplit[2])==i
&&
(that.begin==undefined||that.end==undefined)
){
temp[line].push({day:i,today:true});
that.today=[line,temp[line].length-1];
// 当天
}else if (chkY == that.year && chkM == that.month && i == that.day&&that.value==undefined) {
temp[line].push({day:i,today:true});
that.today=[line,temp[line].length-1];
} else {//默认
// 1.判断begin和end的日期
var options={day:i,today:false};
if(that.begin!=undefined){
var beginSplit=that.begin.split(that.sep);
var beginTime=Number(new Date(parseInt(beginSplit[0]),parseInt(beginSplit[1])-1,parseInt(beginSplit[2])));
var thisTime=Number(new Date(that.year,that.month,i));
if(beginTime>thisTime)options.disabled=true;
}
if(that.end!=undefined){
var endSplit=that.end.split(that.sep);
var endTime=Number(new Date(parseInt(endSplit[0]),parseInt(endSplit[1])-1,parseInt(endSplit[2])));
var thisTime=Number(new Date(that.year,that.month,i));
if(endTime<thisTime)options.disabled=true;
}
temp[line].push(options);
}
}
// 最后一行
if (dow == 6) {
line++;
}else if (i == lastDateOfMonth) {
var k = 1;
for (dow; dow < 6; dow++) {
temp[line].push({day:k,disabled:true});
k++;
}
}
}//end for
that.days=temp;
},
prev:function(e){
e.stopPropagation();
var that=this;
if (that.month == 0) {
that.month = 11;
that.year = that.year - 1;
} else {
that.month = that.month - 1;
}
that.render(that.year,that.month);
},
next:function(e){
e.stopPropagation();
var that=this;
if (that.month == 11) {
that.month = 0;
that.year = that.year + 1;
} else {
that.month = that.month + 1;
}
that.render(that.year,that.month);
},
select:function(k1,k2,e){
if(e!=undefined)e.stopPropagation();
var that=this;
// 日期范围
if(that.range){
if(that.rangeBegin.length==0||that.rangeEndTemp!=0){
that.rangeBegin=[that.year,that.month,that.days[k1][k2].day,that.hour,that.minute,that.second];
that.rangeBeginTemp=that.rangeBegin;
that.rangeEnd=[that.year,that.month,that.days[k1][k2].day,that.hour,that.minute,that.second];
that.rangeEndTemp=0;
}else{
that.rangeEnd=[that.year,that.month,that.days[k1][k2].day,that.hour,that.minute,that.second];
that.rangeEndTemp=1;
// 判断结束日期小于开始日期则自动颠倒过来
if(+new Date(that.rangeEnd[0],that.rangeEnd[1],that.rangeEnd[2])<+new Date(that.rangeBegin[0],that.rangeBegin[1],that.rangeBegin[2])){
that.rangeBegin=that.rangeEnd;
that.rangeEnd=that.rangeBeginTemp;
}
}
that.render(that.year,that.month);
}else{
// 取消上次选中
if(that.today.length>0){
that.days[that.today[0]][that.today[1]].today=false;
}
// 设置当前选中天
that.days[k1][k2].today=true;
that.day=that.days[k1][k2].day;
that.today=[k1,k2];
if(that.type=='date'){
that.value=that.year+that.sep+that.zero(that.month+1)+that.sep+that.zero(that.days[k1][k2].day);
that.show=false;
}
}
},
ok:function(){
var that=this;
if(that.range){
that.value=that.output(that.rangeBegin)+" ~ "+that.output(that.rangeEnd);
}else{
that.value=that.output([that.year,that.month,that.day,that.hour,that.minute,that.second]);
}
that.show=false;
},
cancel:function(){
this.show=false;
},
// 格式化输出
output:function(args){
var that=this;
if(that.type=='time'){
return that.zero(args[3])+":"+that.zero(args[4])+":"+that.zero(args[5])
}
if(that.type=='datetime'){
return args[0]+that.sep+that.zero(args[1]+1)+that.sep+that.zero(args[2])+" "+that.zero(args[3])+":"+that.zero(args[4])+":"+that.zero(args[5])
}
if(that.type=='date'){
return args[0]+that.sep+that.zero(args[1]+1)+that.sep+that.zero(args[2]);
}
},
showCalendar:function(e){
e.stopPropagation();
var that=this;
that.show=true;
that.x=e.target.offsetLeft;
that.y=e.target.offsetTop+e.target.offsetHeight+0;
var bindHide=function(e){
e.stopPropagation();
that.show=false;
document.removeEventListener('click',bindHide,false);
};
setTimeout(function(){
document.addEventListener('click',bindHide,false);
},500);
}
}
}
</script>
... ...
... ... @@ -42,7 +42,7 @@ var Iaccount = {
var apiCofig = {
//root:__dirname,
EnvConst:{
domain:"http://192.168.102.202:8088/platform",
domain:"http://192.168.102.210:8088/platform",
//bigdata:"http://172.16.6.189:8080/bigdata",//李建
bigdata:"http://192.168.102.210:8091/bigdata",
//bigdata:"http://172.16.6.110:8080",//钟文
... ...