kingdot
Version:
A UI Components Library For Vue
1,133 lines (1,031 loc) • 38.3 kB
JavaScript
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/dist/";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 258);
/******/ })
/************************************************************************/
/******/ ({
/***/ 0:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
/* globals __VUE_SSR_CONTEXT__ */
// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
// This module is a runtime utility for cleaner component module output and will
// be included in the final webpack user bundle.
function normalizeComponent (
scriptExports,
render,
staticRenderFns,
functionalTemplate,
injectStyles,
scopeId,
moduleIdentifier, /* server only */
shadowMode /* vue-cli only */
) {
// Vue.extend constructor export interop
var options = typeof scriptExports === 'function'
? scriptExports.options
: scriptExports
// render functions
if (render) {
options.render = render
options.staticRenderFns = staticRenderFns
options._compiled = true
}
// functional template
if (functionalTemplate) {
options.functional = true
}
// scopedId
if (scopeId) {
options._scopeId = 'data-v-' + scopeId
}
var hook
if (moduleIdentifier) { // server build
hook = function (context) {
// 2.3 injection
context =
context || // cached call
(this.$vnode && this.$vnode.ssrContext) || // stateful
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
// 2.2 with runInNewContext: true
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
context = __VUE_SSR_CONTEXT__
}
// inject component styles
if (injectStyles) {
injectStyles.call(this, context)
}
// register component module identifier for async chunk inferrence
if (context && context._registeredComponents) {
context._registeredComponents.add(moduleIdentifier)
}
}
// used by ssr in case component is cached and beforeCreate
// never gets called
options._ssrRegister = hook
} else if (injectStyles) {
hook = shadowMode
? function () {
injectStyles.call(
this,
(options.functional ? this.parent : this).$root.$options.shadowRoot
)
}
: injectStyles
}
if (hook) {
if (options.functional) {
// for template-only hot-reload because in that case the render fn doesn't
// go through the normalizer
options._injectStyles = hook
// register for functional component in vue file
var originalRender = options.render
options.render = function renderWithStyleInjection (h, context) {
hook.call(context)
return originalRender(h, context)
}
} else {
// inject component registration as beforeCreate hook
var existing = options.beforeCreate
options.beforeCreate = existing
? [].concat(existing, hook)
: [hook]
}
}
return {
exports: scriptExports,
options: options
}
}
/***/ }),
/***/ 258:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./components/TimePicker/time-picker.vue?vue&type=template&id=3e7ba628&
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"kd-time-picker"},[_c('kd-tooltip',{attrs:{"placement":"bottom-start","trigger":"click","width-limit":false,"disabled":_vm.disabled},model:{value:(_vm.isTooltipShow),callback:function ($$v) {_vm.isTooltipShow=$$v},expression:"isTooltipShow"}},[_c('kd-input',{class:{
'kd-timepicker-input': true,
'range': _vm.range
},attrs:{"placeholder":_vm.placeholder,"value":_vm.timeString,"disabled":_vm.disabled,"readonly":""}},[(_vm.iconPosition==='prefix')?_c('template',{slot:"prefix"},[_c('i',{staticClass:"kd-icon-time kdicon"})]):_vm._e(),(_vm.iconPosition==='prefix')?_c('template',{slot:"suffix"},[(_vm.clearable && !_vm.disabled && !!_vm.timeString)?_c('i',{staticClass:"kd-icon-close kd-timepicker-close-icon kdicon",on:{"click":function($event){$event.stopPropagation();return _vm.onClear($event)}}}):_vm._e()]):_vm._e(),(_vm.iconPosition==='suffix')?_c('template',{slot:"suffix"},[(_vm.clearable && !_vm.disabled && !!_vm.timeString)?_c('i',{staticClass:"kd-icon-close kd-timepicker-close-icon kdicon",on:{"click":function($event){$event.stopPropagation();return _vm.onClear($event)}}}):_vm._e(),(_vm.clearable && !_vm.disabled && !!_vm.timeString)?_c('i',{staticClass:"kd-icon-time kd-timepicker-time-icon kdicon",on:{"click":function($event){$event.stopPropagation();return _vm.onClear($event)}}}):_c('i',{staticClass:"kd-icon-time kdicon"})]):_vm._e()],2),_c('template',{slot:"content"},[_c('div'),(_vm.isTooltipShow)?_c('div',[(!_vm.range && _vm.mode === 'steptime')?_c('div',{staticClass:"kd-timepicker-panel"},[_c('div',{staticClass:"kd-steptime-container"},[(true)?_c('div',_vm._l((_vm.timeList),function(item,index){return _c('div',{key:index,class:{
'kd-steptime-item': true,
'kd-disabled': _vm.checkDisabled(item),
'kd-active': _vm.timeValue.includes(item)
},on:{"click":function($event){$event.stopPropagation();return _vm.selectTimeValue(item)}}},[_vm._v("\n "+_vm._s(item)+"\n ")])}),0):undefined])]):_vm._e(),(!_vm.range && _vm.mode === 'anytime')?_c('div',{staticClass:"kd-timepicker-panel"},[_c('div',{staticClass:"kd-common-selector-container"},[(_vm.multiple)?_c('Time',{attrs:{"value":_vm.timeValue[_vm.timeValue.length - 1],"min":_vm.minTime,"max":_vm.maxTime,"disabled":_vm.disabledColumn,"disabled-list":_vm.disabledTime,"accuracy":_vm.accuracy},on:{"change":_vm.timeValueChange}}):_c('Time',{attrs:{"min":_vm.minTime,"max":_vm.maxTime,"disabled":_vm.disabledColumn,"disabled-list":_vm.disabledTime,"accuracy":_vm.accuracy},on:{"change":_vm.timeValueChange},model:{value:(_vm.timeValue[0]),callback:function ($$v) {_vm.$set(_vm.timeValue, 0, $$v)},expression:"timeValue[0]"}})],1)]):_vm._e(),(_vm.range)?_c('div',{staticClass:"kd-timepicker-panel range"},[_c('div',[_c('div',{staticClass:"kd-timepicker-title"},[_vm._v("开始时间")]),(_vm.mode === 'steptime')?_c('div',{staticClass:"kd-range-selector-container"},[_c('kd-scroll-select',{ref:"startTimeSelector",attrs:{"data":_vm.timeList,"disable":_vm.startTimeSelectorLimit()},model:{value:(_vm.timeValue[0]),callback:function ($$v) {_vm.$set(_vm.timeValue, 0, $$v)},expression:"timeValue[0]"}})],1):_vm._e(),(_vm.mode === 'anytime')?_c('div',{staticClass:"kd-range-selector-container"},[_c('Time',{attrs:{"min":_vm.minTime,"max":_vm.startTimeMaxLimit(_vm.maxTime, _vm.timeValue[1]),"disabled":_vm.disabledColumn,"disabled-list":_vm.disabledTime,"accuracy":_vm.accuracy},on:{"change":_vm.timeValueChange},model:{value:(_vm.timeValue[0]),callback:function ($$v) {_vm.$set(_vm.timeValue, 0, $$v)},expression:"timeValue[0]"}})],1):_vm._e()]),_c('div',[_c('div',{staticClass:"kd-timepicker-title"},[_vm._v("结束时间")]),(_vm.mode === 'steptime')?_c('div',{staticClass:"kd-range-selector-container"},[_c('kd-scroll-select',{ref:"endTimeSelector",attrs:{"data":_vm.timeList,"disable":_vm.endTimeSelectorLimit()},model:{value:(_vm.timeValue[1]),callback:function ($$v) {_vm.$set(_vm.timeValue, 1, $$v)},expression:"timeValue[1]"}})],1):_vm._e(),(_vm.mode === 'anytime')?_c('div',{staticClass:"kd-range-selector-container"},[_c('Time',{attrs:{"min":_vm.endTimeMinLimit(_vm.minTime, _vm.timeValue[0]),"max":_vm.maxTime,"disabled":_vm.disabledColumn,"disabled-list":_vm.disabledTime,"accuracy":_vm.accuracy},on:{"change":_vm.timeValueChange},model:{value:(_vm.timeValue[1]),callback:function ($$v) {_vm.$set(_vm.timeValue, 1, $$v)},expression:"timeValue[1]"}})],1):_vm._e()])]):_vm._e(),(_vm.showFooter)?_c('div',{staticClass:"kd-time-picker-footer"},[_c('kd-button',{attrs:{"hollow":"","size":"mini"},on:{"click":_vm.cancelChange}},[_vm._v("取消")]),_c('kd-button',{attrs:{"hollow":"","size":"mini"},on:{"click":_vm.confirmChange}},[_vm._v("确认")])],1):_vm._e()]):_vm._e()])],2)],1)}
var staticRenderFns = []
// CONCATENATED MODULE: ./components/TimePicker/time-picker.vue?vue&type=template&id=3e7ba628&
// EXTERNAL MODULE: ./components/TimePicker/Time.vue + 4 modules
var Time = __webpack_require__(90);
// EXTERNAL MODULE: ./components/TimePicker/utils.js
var utils = __webpack_require__(9);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./components/TimePicker/time-picker.vue?vue&type=script&lang=js&
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var time_pickervue_type_script_lang_js_ = ({
name: 'KdTimePicker',
components: {
Time: Time["a" /* default */]
},
props: {
value: {
type: [String, Array]
},
disabled: { // 组件禁用
type: Boolean,
default: false
},
// 满足某条件的时间将被禁用
disabledTime: {
type: [Array, Function],
default: function _default() {
return [];
}
},
// 显示模式: 'steptime', 'anytime', 按步长显示时间, 任意时间点
mode: {
type: String,
default: 'anytime'
},
minTime: {
type: String,
default: '00:00:00'
},
maxTime: {
type: String,
default: '23:59:59'
},
step: {
type: [Number, String],
default: 30
},
range: {
type: Boolean,
default: false
},
multiple: {
type: Boolean,
default: false
},
placeholder: {
type: String,
default: '选择时间'
},
optionalTimes: {
type: Array
},
clearable: {
type: Boolean,
default: function _default() {
return true;
}
},
disabledColumn: {
type: Array,
default: function _default() {
return [false, false, false];
}
},
accuracy: {
type: String,
default: function _default() {
return 'secend';
}
},
hideFooter: {
type: Boolean,
default: function _default() {
return false;
}
},
// prefix, suffix
iconPosition: {
type: String,
default: function _default() {
return 'prefix';
}
}
},
data: function data() {
var _this = this;
return {
scrollTimeArr: Array.apply(null, { length: 3 }).map(function (item, index) {
var length = index === 0 ? 24 : 60;
return Array(length).fill(0).map(function (x, i) {
return _this.addPreZero(i);
});
}),
timeValue: [], // innervalue
timeString: '', // input value
tooltipShowFlag: false,
onShowValue: Array.isArray(this.value) ? [].concat(_toConsumableArray(this.value)) : this.value,
isTooltipShow: false
};
},
computed: {
showFooter: function showFooter() {
return !this.hideFooter && this.mode === 'anytime';
},
timeList: function timeList() {
if (!!this.optionalTimes && Array.isArray(this.optionalTimes)) {
// 传入不规则的时间列表
return this.optionalTimes;
} else if (this.mode === 'steptime') {
var step = Number(this.step) ? Number(this.step) * 60 : Object(utils["b" /* parseTime */])(this.step);
var max = Object(utils["b" /* parseTime */])(this.maxTime);
var min = Object(utils["b" /* parseTime */])(this.minTime);
var data = [];
for (var t = min; t <= max; t += step) {
data.push(Object(utils["d" /* stringTime */])(t, 'minute'));
}
// this.timeList = data;
// 固定时间点, 不展示秒..
return data;
} else {
return [];
}
}
},
watch: {
value: {
immediate: true,
handler: function handler(v) {
if (!v) {
v = '';
}
if (typeof v === 'string') {
// 单
// TODO: 检查合法性. 不规范字符串, 空值 null undefined
// A: 转成空字符串
this.timeString = v;
this.timeValue = [v];
} else if (Array.isArray(v)) {
// 范围
if (!this.multiple && v.length < 2) return;
this.timeValue = v;
this.timeString = v.join(this.multiple ? ',' : ' - ');
}
}
},
timeValue: {
deep: true,
handler: function handler(v) {
if (this.range) {
this.timeString = this.timeValue.join(' - ');
this.$emit('input', this.timeValue);
} else if (this.multiple) {
this.timeString = this.timeValue.join(',');
this.$emit('input', this.timeValue);
} else {
this.timeString = this.timeValue[0];
this.$emit('input', this.timeValue[0]);
}
}
},
isTooltipShow: function isTooltipShow(v) {
this.onShowValue = Array.isArray(this.value) ? [].concat(_toConsumableArray(this.value)) : this.value;
if (v) {
this.tooltipShowFlag = true;
} else {
this.tooltipShowFlag = false;
}
}
},
created: function created() {},
methods: {
cancelChange: function cancelChange() {
this.isTooltipShow = false;
if (this.onShowValue.toString() !== this.value.toString()) {
this.$emit('input', this.onShowValue);
this.$emit('change', this.onShowValue);
}
},
confirmChange: function confirmChange() {
this.isTooltipShow = false;
},
onClear: function onClear(e) {
e.stopPropagation();
this.timeString = '';
this.$emit('clear');
// this.$emit('change', this.dateValue, 'clear');
if (this.range || this.multiple) {
// inner value
this.timeValue = [];
this.$emit('change', [], 'clear');
} else {
this.timeValue = [];
this.$emit('change', '', 'clear');
}
},
selectTimeValue: function selectTimeValue(item) {
if (this.checkDisabled(item)) return;
if (this.multiple) {
if (!this.range && this.mode === 'steptime') {
var index = this.timeValue.findIndex(function (i) {
return i === item;
});
if (~index) {
this.timeValue.splice(index, 1);
} else {
this.timeValue.push(item);
}
this.$emit('change', this.timeValue, 'select');
} else if (!this.timeValue.includes(item)) {
if (this.tooltipShowFlag) {
this.timeValue.push(item);
this.tooltipShowFlag = false;
} else {
this.timeValue.splice(this.timeValue.length - 1, 1, item);
}
this.$emit('change', this.timeValue, 'select');
}
} else if (this.timeString !== item) {
this.timeValue = [item];
// this.timeString = item;
// this.$emit('input', item);
this.$emit('change', item, 'select');
this.isTooltipShow = false;
}
},
addPreZero: function addPreZero(num) {
return ('00' + String(num)).slice(-2);
},
startTimeMaxLimit: function startTimeMaxLimit() {
for (var _len = arguments.length, times = Array(_len), _key = 0; _key < _len; _key++) {
times[_key] = arguments[_key];
}
times = times.map(function (item) {
return Object(utils["b" /* parseTime */])(item || '23:59:59');
});
return Object(utils["d" /* stringTime */])(Math.min.apply(null, times));
},
endTimeMinLimit: function endTimeMinLimit() {
for (var _len2 = arguments.length, times = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
times[_key2] = arguments[_key2];
}
times = times.map(function (item) {
return Object(utils["b" /* parseTime */])(item || '00:00:00');
});
return Object(utils["d" /* stringTime */])(Math.max.apply(null, times));
},
timeValueChange: function timeValueChange(value) {
if (this.multiple) {
if (!this.timeValue.includes(value)) {
if (this.tooltipShowFlag) {
this.timeValue.push(value);
this.tooltipShowFlag = false;
} else {
this.timeValue.splice(this.timeValue.length - 1, 1, value);
}
this.$emit('change', this.timeValue, 'scroll'); // 通过滚动选的时间
}
} else if (this.timeString !== value) {
this.$emit('change', value, 'scroll'); // 通过滚动选的时间
}
},
checkDisabled: function checkDisabled(timeStr) {
var disable = false;
if (this.disabledTime) {
if (Array.isArray(this.disabledTime)) {
disable = disable || this.disabledTime.includes(timeStr);
}
if (typeof this.disabledTime === 'function') {
disable = disable || this.disabledTime(timeStr);
}
}
return disable;
},
startTimeSelectorLimit: function startTimeSelectorLimit() {
var _this2 = this;
// let max = 生成的timelist 已经遵循 min max 限制
return function (time) {
// "02:00"
var disabled = false;
disabled = Object(utils["b" /* parseTime */])(time) > Object(utils["b" /* parseTime */])(_this2.timeValue[1]);
return disabled;
};
},
endTimeSelectorLimit: function endTimeSelectorLimit() {
var _this3 = this;
return function (time) {
// "02:00"
var disabled = false;
disabled = Object(utils["b" /* parseTime */])(time) < Object(utils["b" /* parseTime */])(_this3.timeValue[0]);
return disabled;
};
}
}
});
// CONCATENATED MODULE: ./components/TimePicker/time-picker.vue?vue&type=script&lang=js&
/* harmony default export */ var TimePicker_time_pickervue_type_script_lang_js_ = (time_pickervue_type_script_lang_js_);
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
// CONCATENATED MODULE: ./components/TimePicker/time-picker.vue
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
TimePicker_time_pickervue_type_script_lang_js_,
render,
staticRenderFns,
false,
null,
null,
null
)
/* harmony default export */ var time_picker = (component.exports);
// CONCATENATED MODULE: ./components/TimePicker/index.js
time_picker.install = function (Vue) {
Vue.component(time_picker.name, time_picker);
};
/* harmony default export */ var TimePicker = __webpack_exports__["default"] = (time_picker);
/***/ }),
/***/ 9:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return strPad; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return parseTime; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return stringTime; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getDateString; });
/* unused harmony export getTimeString */
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
function strPad(str, length, pad) {
str = str.toString();
pad = pad === undefined ? '0' : pad;
var l = str.length;
if (l < length) {
str = new Array(length - l + 1).join(pad) + str;
}
return str;
}
// 可接受 数组 或 时间字符串 "01:00:00" 输出以秒为单位的时间 number 值
function parseTime(time) {
var h = 0;
var m = 0;
var s = 0;
if (typeof time === 'string') {
var _time$split$map = time.split(':').map(function (i) {
return Number(i);
});
var _time$split$map2 = _slicedToArray(_time$split$map, 3);
var _time$split$map2$ = _time$split$map2[0];
h = _time$split$map2$ === undefined ? 0 : _time$split$map2$;
var _time$split$map2$2 = _time$split$map2[1];
m = _time$split$map2$2 === undefined ? 0 : _time$split$map2$2;
var _time$split$map2$3 = _time$split$map2[2];
s = _time$split$map2$3 === undefined ? 0 : _time$split$map2$3;
} else if (Array.isArray(time)) {
var _time$map = time.map(function (i) {
return Number(i);
});
var _time$map2 = _slicedToArray(_time$map, 3);
var _time$map2$ = _time$map2[0];
h = _time$map2$ === undefined ? 0 : _time$map2$;
var _time$map2$2 = _time$map2[1];
m = _time$map2$2 === undefined ? 0 : _time$map2$2;
var _time$map2$3 = _time$map2[2];
s = _time$map2$3 === undefined ? 0 : _time$map2$3;
}
return (h * 60 + m) * 60 + s;
}
// 可接受 时间戳, 不规整时间字符串 "1:1:00", 输出规整时间字符串"01:01:00"
function stringTime(time) {
var accuracy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'second';
var h = 0;
var m = 0;
var s = 0;
if (typeof time === 'number') {
h = Math.floor(time / 3600);
m = Math.floor(time % 3600 / 60);
s = time % 60;
} else if (typeof time === 'string') {
var _time$split$map3 = time.split(':').map(function (i) {
return Number(i);
});
var _time$split$map4 = _slicedToArray(_time$split$map3, 3);
var _time$split$map4$ = _time$split$map4[0];
h = _time$split$map4$ === undefined ? 0 : _time$split$map4$;
var _time$split$map4$2 = _time$split$map4[1];
m = _time$split$map4$2 === undefined ? 0 : _time$split$map4$2;
var _time$split$map4$3 = _time$split$map4[2];
s = _time$split$map4$3 === undefined ? 0 : _time$split$map4$3;
} else {
return new Error('stringTime 传入参数格式错误. ');
}
if (accuracy === 'minute') {
return strPad(h, 2) + ':' + strPad(m, 2);
} else {
return strPad(h, 2) + ':' + strPad(m, 2) + ':' + strPad(s, 2);
}
}
function getDateString(date, type) {
var year = '' + date.getFullYear();
if (type === 'year') {
return year;
}
var month = year + '-' + strPad(date.getMonth() + 1, 2);
if (type === 'month') {
return month;
}
var _date = month + '-' + strPad(date.getDate(), 2);
if (type !== 'datetime') {
return _date;
}
return _date + ' ' + getTimeString(date);
}
function getTimeString(date) {
return [strPad(date.getHours(), 2), strPad(date.getMinutes(), 2), strPad(date.getSeconds(), 2)].join(':');
}
/***/ }),
/***/ 90:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./components/TimePicker/Time.vue?vue&type=template&id=732a2d67&
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"kd-time-panel"},_vm._l((_vm.data),function(item,index){return _c('div',{key:index,staticClass:"column"},[_c('kd-scroll-select',{ref:"ScrollSelect",refInFor:true,attrs:{"data":item,"disable":_vm.getScrollDisable(index),"disabled":_vm.scrollDisabled[index]},model:{value:(_vm.timeValue[index]),callback:function ($$v) {_vm.$set(_vm.timeValue, index, $$v)},expression:"timeValue[index]"}})],1)}),0)}
var staticRenderFns = []
// CONCATENATED MODULE: ./components/TimePicker/Time.vue?vue&type=template&id=732a2d67&
// EXTERNAL MODULE: ./components/TimePicker/utils.js
var utils = __webpack_require__(9);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./components/TimePicker/Time.vue?vue&type=script&lang=js&
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var Timevue_type_script_lang_js_ = ({
props: {
value: {
type: [String, Array]
},
min: {
type: [String, Date]
},
max: {
type: [String, Date]
},
step: {
type: [String, Number]
},
date: { // date-time 模式, 需要传入 date 信息
type: [String, Date]
},
disabled: { // 管理scrollSelect组件禁用状态
type: Array,
default: function _default() {
return [];
}
},
disabledList: { // 指定禁用的时间. 可以是列表, 也可以是函数
type: [Array, Function],
default: function _default() {
return [];
}
},
accuracy: {
type: String,
default: function _default() {
return 'secend';
}
}
// count: {
// type: Number
// }
},
data: function data() {
return {
timeValue: [], // 设定 time 面板被框选的默认值
disabledItems: this.disabled || [false, false, false],
baseDate: '',
maxTime: this.max, // 完整的时间日期字符串, 或者 "00:00:00"
minTime: this.min
};
},
computed: {
data: function data() {
return Array.apply(null, { length: this.accuracy === 'minute' ? 2 : 3 }).map(function (item, index) {
var length = index === 0 ? 24 : 60;
return Array(length).fill(0).map(function (x, i) {
return Object(utils["c" /* strPad */])(i, 2);
});
});
},
// stepData() {
// if (!this.step) return [];
// const step = this.parseTime(this.step || '00:30:00');
// const max = this.parseTime(this.maxTime || '23:59:59');
// const min = this.parseTime(this.minTime || '00:00:00');
// const data = [];
// for (let i = min; i <= max; i += step) {
// data.push(this.stringTime(i));
// }
// return data;
// },
scrollDisabled: function scrollDisabled() {
return this.disabledItems;
}
},
watch: {
value: {
immediate: true,
handler: function handler(v) {
// if (!v) {
// this.timeValue = [];
// return;
// }
if (Array.isArray(v)) {
this.timeValue = v; // 给 innerValue 赋值
} else if (!!v && typeof v === 'string') {
this.timeValue = (v || '00:00:00').split(':');
}
}
},
disabled: {
immediate: true,
handler: function handler(v) {
this.disabledItems = v || [false, false, false];
}
},
date: {
immediate: true,
handler: function handler(v) {
this.baseDate = Object(utils["a" /* getDateString */])(v ? new Date(v) : new Date(), 'date');
}
},
max: {
immediate: true,
handler: function handler(v) {
this.maxTime = v;
}
},
min: { // 00:00:00
immediate: true,
handler: function handler(v) {
this.minTime = v;
}
},
timeValue: function timeValue(value, oldValue) {
// timeValue 是数组, oldValue 和value 一样
// oldValue = oldValue && oldValue.join(':');
value = value.join(':');
value = Object(utils["d" /* stringTime */])(value, this.accuracy);
if (this.value !== value) {
// 防止多次change
this.$emit('input', value); // 传递给上层的 触发 value 变化. 上层 value 是字符串
this.$emit('change', value);
}
}
},
created: function created() {},
methods: {
// parseTime(time) {
// let [h = 0, m = 0, s = 0] = time.split(':').map(i => +i);
// return (h * 60 + m) * 60 + s;
// },
// stringTime(time) {
// let h = Math.floor(time / 3600);
// let m = Math.floor((time % 3600) / 60);
// let s = time % 60;
// return `${strPad(h, 2)}:${strPad(m, 2)}:${strPad(s, 2)}`;
// },
getScrollDisable: function getScrollDisable(index) {
var _this = this;
return function (value) {
var time = [].concat(_toConsumableArray(_this.timeValue)).map(function (item, i) {
if (_this.$refs.ScrollSelect && _this.$refs.ScrollSelect[i]) {
return _this.$refs.ScrollSelect[i].currentValue;
}
return item;
});
// this.minTime 09:00:00, 或者 mintime 是完整的时间字符串, 并且给date
// baseDate: 给了 this.date , 一致. 没给this.date 今天
var min = _this.date ? _this.minTime : _this.baseDate + ' ' + _this.minTime;
var max = _this.date ? _this.maxTime : _this.baseDate + ' ' + _this.maxTime;
var disable = false;
time[index] = value;
var timeStr = time.join(':');
time = new Date(_this.baseDate + ' ' + timeStr);
if (_this.minTime && _this.maxTime) {
disable = time < new Date('' + min) || time > new Date('' + max);
} else if (_this.minTime) {
disable = time < new Date('' + min);
} else if (_this.maxTime) {
disable = time > new Date('' + max);
}
if (_this.disabledList) {
if (Array.isArray(_this.disabledList)) {
disable = disable || _this.disabledList.includes(timeStr); // string 格式的时间
}
if (typeof _this.disabledList === 'function') {
disable = disable || _this.disabledList(timeStr);
}
}
return disable;
};
}
}
});
// CONCATENATED MODULE: ./components/TimePicker/Time.vue?vue&type=script&lang=js&
/* harmony default export */ var TimePicker_Timevue_type_script_lang_js_ = (Timevue_type_script_lang_js_);
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
// CONCATENATED MODULE: ./components/TimePicker/Time.vue
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
TimePicker_Timevue_type_script_lang_js_,
render,
staticRenderFns,
false,
null,
null,
null
)
/* harmony default export */ var Time = __webpack_exports__["a"] = (component.exports);
/***/ })
/******/ })["default"];