"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var utils_1 = require("../common/utils");
var shared_1 = require("../picker/shared");
var currentYear = new Date().getFullYear();
function isValidDate(date) {
return utils_1.isDef(date) && !isNaN(new Date(date).getTime());
}
function range(num, min, max) {
return Math.min(Math.max(num, min), max);
}
function padZero(val) {
return ("00" + val).slice(-2);
}
function times(n, iteratee) {
var index = -1;
var result = Array(n);
while (++index < n) {
result[index] = iteratee(index);
}
return result;
}
function getTrueValue(formattedValue) {
if (!formattedValue)
return;
while (isNaN(parseInt(formattedValue, 10))) {
formattedValue = formattedValue.slice(1);
}
return parseInt(formattedValue, 10);
}
function getMonthEndDay(year, month) {
return 32 - new Date(year, month - 1, 32).getDate();
}
var defaultFormatter = function (_, value) { return value; };
component_1.VantComponent({
classes: ['active-class', 'toolbar-class', 'column-class'],
props: __assign({}, shared_1.pickerProps, { formatter: {
type: Function,
value: defaultFormatter
}, value: null, type: {
type: String,
value: 'datetime'
}, showToolbar: {
type: Boolean,
value: true
}, minDate: {
type: Number,
value: new Date(currentYear - 10, 0, 1).getTime()
}, maxDate: {
type: Number,
value: new Date(currentYear + 10, 11, 31).getTime()
}, minHour: {
type: Number,
value: 0
}, maxHour: {
type: Number,
value: 23
}, minMinute: {
type: Number,
value: 0
}, maxMinute: {
type: Number,
value: 59
} }),
data: {
innerValue: Date.now(),
columns: []
},
watch: {
value: function (val) {
var _this = this;
var data = this.data;
val = this.correctValue(val);
var isEqual = val === data.innerValue;
if (!isEqual) {
this.updateColumnValue(val).then(function () {
_this.$emit('input', val);
});
}
},
type: 'updateColumns',
minHour: 'updateColumns',
maxHour: 'updateColumns',
minMinute: 'updateColumns',
maxMinute: 'updateColumns'
},
methods: {
getPicker: function () {
if (this.picker == null) {
var picker_1 = (this.picker = this.selectComponent('.van-datetime-picker'));
var setColumnValues_1 = picker_1.setColumnValues;
picker_1.setColumnValues = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return setColumnValues_1.apply(picker_1, args.concat([false]));
};
}
return this.picker;
},
updateColumns: function () {
var _a = this.data.formatter, formatter = _a === void 0 ? defaultFormatter : _a;
var results = this.getRanges().map(function (_a, index) {
var type = _a.type, range = _a.range;
var values = times(range[1] - range[0] + 1, function (index) {
var value = range[0] + index;
value = type === 'year' ? "" + value : padZero(value);
return formatter(type, value);
});
return { values: values };
});
return this.set({ columns: results });
},
getRanges: function () {
var data = this.data;
if (data.type === 'time') {
return [
{
type: 'hour',
range: [data.minHour, data.maxHour]
},
{
type: 'minute',
range: [data.minMinute, data.maxMinute]
}
];
}
var _a = this.getBoundary('max', data.innerValue), maxYear = _a.maxYear, maxDate = _a.maxDate, maxMonth = _a.maxMonth, maxHour = _a.maxHour, maxMinute = _a.maxMinute;
var _b = this.getBoundary('min', data.innerValue), minYear = _b.minYear, minDate = _b.minDate, minMonth = _b.minMonth, minHour = _b.minHour, minMinute = _b.minMinute;
var result = [
{
type: 'year',
range: [minYear, maxYear]
},
{
type: 'month',
range: [minMonth, maxMonth]
},
{
type: 'day',
range: [minDate, maxDate]
},
{
type: 'hour',
range: [minHour, maxHour]
},
{
type: 'minute',
range: [minMinute, maxMinute]
}
];
if (data.type === 'date')
result.splice(3, 2);
if (data.type === 'year-month')
result.splice(2, 3);
return result;
},
correctValue: function (value) {
var data = this.data;
// validate value
var isDateType = data.type !== 'time';
if (isDateType && !isValidDate(value)) {
value = data.minDate;
}
else if (!isDateType && !value) {
var minHour = data.minHour;
value = padZero(minHour) + ":00";
}
// time type
if (!isDateType) {
var _a = value.split(':'), hour = _a[0], minute = _a[1];
hour = padZero(range(hour, data.minHour, data.maxHour));
minute = padZero(range(minute, data.minMinute, data.maxMinute));
return hour + ":" + minute;
}
// date type
value = Math.max(value, data.minDate);
value = Math.min(value, data.maxDate);
return value;
},
getBoundary: function (type, innerValue) {
var _a;
var value = new Date(innerValue);
var boundary = new Date(this.data[type + "Date"]);
var year = boundary.getFullYear();
var month = 1;
var date = 1;
var hour = 0;
var minute = 0;
if (type === 'max') {
month = 12;
date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1);
hour = 23;
minute = 59;
}
if (value.getFullYear() === year) {
month = boundary.getMonth() + 1;
if (value.getMonth() + 1 === month) {
date = boundary.getDate();
if (value.getDate() === date) {
hour = boundary.getHours();
if (value.getHours() === hour) {
minute = boundary.getMinutes();
}
}
}
}
return _a = {},
_a[type + "Year"] = year,
_a[type + "Month"] = month,
onnx
- 粉丝: 1w+
- 资源: 5627
最新资源
- 电动汽车空调制冷系统电动压缩机匹配分析1.pdf
- 二氧化碳汽车空调系统设计及研究1.pdf
- 电动汽车驱动系统散热设计与试验验证.pdf
- McQuayDuctSizer(麦克维尔风管尺寸计算软件).zip
- 麦克维尔温湿度分析仪McQuayPsychrometricAnalyzer(hvac-eng.com).zip
- 麦克维尔管道测量仪McQuaypipesizer .zip
- 信捷XC系列PLC主从通讯程序
- 基于蒙特卡洛的电动汽车充电负荷生成
- 基于遗传算法的电动汽车有序充电优化调度 软件:Matlab 利用遗传算法对电动汽车有序充电进行优化;优化目标包括充电费用最低,充电时间达到要求(电动汽车充到足够的电)考虑电动汽车充电对电网负荷的影响
- FPGA 全部verilog代码实现I2C口master端口应用场景 1、FPGA通过I2C口配置TFP410MP 2、EDID配置,FPGA通过I2C口配置AT24C02 AT24C64; 访问地
- Matlab simulink 基于光伏和蓄电池的三端口
- FFT STM32+apFFT程序源代码+lunwen资料+教程讲解 适用于STM32F103平台,使用AD7606同步采集两路正弦信号,内置1024点全相位快速傅里叶变(apFFT)算法,直接计算
- 两电平svpwm算法verilog程序
- 基于改进的快速粒子群有源配电网动态无功优化 软件:Matlab 介绍:在含分布式电源的IEEE33进行无功优化,以无功最优和运行费用最优为目标函数进行优化,采用改进的快速粒子群算法进行计算
- 混合型APF,HAPF,电力牵引系统电能质量控制,高铁谐波补偿,高铁无功补偿,混合型有源电力滤波器,单相SVG,SVG,电力牵引系统谐波无功补偿
- 单机无穷大系统静态稳定性仿真模型
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈