Commit a0c3c115 by 葛青博

修改选择日期范围

1 parent bfaadc58
// 自定义时间 // 自定义时间
let createCustomTime = () => { let createCustomTime = () => {
let customDate=[] let customDate = [],
, obj = {}; obj = {};
let hmsArr = []; let hmsArr = [];
let hours = [] let hours = [],
, minutes = [] minutes = [],
, seconds = [] seconds = [],
, hourObj = {}; hourObj = {};
for(let h = 0; h < 24; h++) { for (let h = 0; h < 24; h++) {
let hVal = h + 1; let hVal = h + 1;
hVal = hVal > 9 ? hVal : '0' + hVal; hVal = hVal > 9 ? hVal : '0' + hVal;
hourObj = { hourObj = {
value: hVal, value: hVal,
children: [] children: []
} }
for(let m = 0; m < 60; m++) { for (let m = 0; m < 60; m++) {
let mVal = m + 1; let mVal = m + 1;
mVal = mVal > 9 ? mVal : '0' + mVal; mVal = mVal > 9 ? mVal : '0' + mVal;
let minutesObj = { let minutesObj = {
value: mVal, value: mVal,
children: [] children: []
}; };
hourObj.children.push(minutesObj) hourObj.children.push(minutesObj)
for(let s = 0; s < 60; s++) { for (let s = 0; s < 60; s++) {
let sVal = s + 1; let sVal = s + 1;
sVal = sVal > 9 ? sVal : '0' + sVal; sVal = sVal > 9 ? sVal : '0' + sVal;
let secondsObj = { let secondsObj = {
value: sVal value: sVal
} }
hourObj.children[m].children.push(secondsObj) hourObj.children[m].children.push(secondsObj)
} }
} }
hours.push(hourObj) hours.push(hourObj)
} }
for(let i = 1999; i < 2020; i++) { for (let i = 1999; i < 2040; i++) {
obj = { obj = {
'value': i + '年', 'value': i + '年',
children: [] children: []
} }
for(let j = 0; j < 12; j++) { for (let j = 0; j < 12; j++) {
let val = j + 1; let val = j + 1;
val = val > 9 ? val : '0' + val; val = val > 9 ? val : '0' + val;
let obj2 = { let obj2 = {
'value': val + '月', 'value': val + '月',
children: [] children: []
} }
obj.children.push(obj2) obj.children.push(obj2)
let day = new Date(i, j + 1, 0); let day = new Date(i, j + 1, 0);
let daycount = day.getDate(); let daycount = day.getDate();
for(let k = 0; k < daycount; k++) { for (let k = 0; k < daycount; k++) {
let val = k + 1; let val = k + 1;
val = val > 9 ? val : '0' + val; val = val > 9 ? val : '0' + val;
let obj3 = { let obj3 = {
'value': val + '日', 'value': val + '日',
children: [] children: []
} }
obj3.children = hours; obj3.children = hours;
obj.children[j].children.push(obj3); obj.children[j].children.push(obj3);
} }
} }
customDate.push(obj) customDate.push(obj)
} }
return customDate; return customDate;
} }
// 日级时间 // 日级时间
let createDayTime = () => { let createDayTime = () => {
let dayDate=[] let dayDate = [],
, obj = {}; obj = {};
for(let i = 1999; i < 2020; i++) { for (let i = 1999; i < 2040; i++) {
obj = { obj = {
'value': i + '年', 'value': i + '年',
children: [] children: []
} }
for(let j = 0; j < 12; j++) { for (let j = 0; j < 12; j++) {
let val = j + 1; let val = j + 1;
val = val > 9 ? val : '0' + val; val = val > 9 ? val : '0' + val;
let obj2 = { let obj2 = {
'value': val + '月', 'value': val + '月',
children: [] children: []
} }
obj.children.push(obj2) obj.children.push(obj2)
let day = new Date(i, j + 1, 0); let day = new Date(i, j + 1, 0);
let daycount = day.getDate(); let daycount = day.getDate();
for(let k = 0; k < daycount; k++) { for (let k = 0; k < daycount; k++) {
let val = k + 1; let val = k + 1;
val = val > 9 ? val : '0' + val; val = val > 9 ? val : '0' + val;
let obj3 = { let obj3 = {
'value': val + '日', 'value': val + '日',
// children: [] // children: []
} }
obj2.children.push(obj3); obj2.children.push(obj3);
} }
} }
dayDate.push(obj) dayDate.push(obj)
} }
return dayDate; return dayDate;
} }
const _customTime = createCustomTime(); const _customTime = createCustomTime();
...@@ -104,13 +104,13 @@ const _customTime = createCustomTime(); ...@@ -104,13 +104,13 @@ const _customTime = createCustomTime();
export default { export default {
getCustomTime(cb) { getCustomTime(cb) {
setTimeout(() => cb(_customTime), 100) setTimeout(() => cb(_customTime), 100)
}, },
getDayTime(cb) { getDayTime(cb) {
cb(createDayTime()) cb(createDayTime())
}, },
getStartEndTime(cb) { getStartEndTime(cb) {
cb(createDayTime()) cb(createDayTime())
} }
} }
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!