date-picker.js 143 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396
  1. module.exports =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, {
  41. /******/ configurable: false,
  42. /******/ enumerable: true,
  43. /******/ get: getter
  44. /******/ });
  45. /******/ }
  46. /******/ };
  47. /******/
  48. /******/ // getDefaultExport function for compatibility with non-harmony modules
  49. /******/ __webpack_require__.n = function(module) {
  50. /******/ var getter = module && module.__esModule ?
  51. /******/ function getDefault() { return module['default']; } :
  52. /******/ function getModuleExports() { return module; };
  53. /******/ __webpack_require__.d(getter, 'a', getter);
  54. /******/ return getter;
  55. /******/ };
  56. /******/
  57. /******/ // Object.prototype.hasOwnProperty.call
  58. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  59. /******/
  60. /******/ // __webpack_public_path__
  61. /******/ __webpack_require__.p = "/dist/";
  62. /******/
  63. /******/ // Load entry module and return exports
  64. /******/ return __webpack_require__(__webpack_require__.s = 176);
  65. /******/ })
  66. /************************************************************************/
  67. /******/ ({
  68. /***/ 0:
  69. /***/ (function(module, exports) {
  70. /* globals __VUE_SSR_CONTEXT__ */
  71. // IMPORTANT: Do NOT use ES2015 features in this file.
  72. // This module is a runtime utility for cleaner component module output and will
  73. // be included in the final webpack user bundle.
  74. module.exports = function normalizeComponent (
  75. rawScriptExports,
  76. compiledTemplate,
  77. functionalTemplate,
  78. injectStyles,
  79. scopeId,
  80. moduleIdentifier /* server only */
  81. ) {
  82. var esModule
  83. var scriptExports = rawScriptExports = rawScriptExports || {}
  84. // ES6 modules interop
  85. var type = typeof rawScriptExports.default
  86. if (type === 'object' || type === 'function') {
  87. esModule = rawScriptExports
  88. scriptExports = rawScriptExports.default
  89. }
  90. // Vue.extend constructor export interop
  91. var options = typeof scriptExports === 'function'
  92. ? scriptExports.options
  93. : scriptExports
  94. // render functions
  95. if (compiledTemplate) {
  96. options.render = compiledTemplate.render
  97. options.staticRenderFns = compiledTemplate.staticRenderFns
  98. options._compiled = true
  99. }
  100. // functional template
  101. if (functionalTemplate) {
  102. options.functional = true
  103. }
  104. // scopedId
  105. if (scopeId) {
  106. options._scopeId = scopeId
  107. }
  108. var hook
  109. if (moduleIdentifier) { // server build
  110. hook = function (context) {
  111. // 2.3 injection
  112. context =
  113. context || // cached call
  114. (this.$vnode && this.$vnode.ssrContext) || // stateful
  115. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  116. // 2.2 with runInNewContext: true
  117. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  118. context = __VUE_SSR_CONTEXT__
  119. }
  120. // inject component styles
  121. if (injectStyles) {
  122. injectStyles.call(this, context)
  123. }
  124. // register component module identifier for async chunk inferrence
  125. if (context && context._registeredComponents) {
  126. context._registeredComponents.add(moduleIdentifier)
  127. }
  128. }
  129. // used by ssr in case component is cached and beforeCreate
  130. // never gets called
  131. options._ssrRegister = hook
  132. } else if (injectStyles) {
  133. hook = injectStyles
  134. }
  135. if (hook) {
  136. var functional = options.functional
  137. var existing = functional
  138. ? options.render
  139. : options.beforeCreate
  140. if (!functional) {
  141. // inject component registration as beforeCreate hook
  142. options.beforeCreate = existing
  143. ? [].concat(existing, hook)
  144. : [hook]
  145. } else {
  146. // for template-only hot-reload because in that case the render fn doesn't
  147. // go through the normalizer
  148. options._injectStyles = hook
  149. // register for functioal component in vue file
  150. options.render = function renderWithStyleInjection (h, context) {
  151. hook.call(context)
  152. return existing(h, context)
  153. }
  154. }
  155. }
  156. return {
  157. esModule: esModule,
  158. exports: scriptExports,
  159. options: options
  160. }
  161. }
  162. /***/ }),
  163. /***/ 1:
  164. /***/ (function(module, exports) {
  165. module.exports = require("element-ui/lib/mixins/emitter");
  166. /***/ }),
  167. /***/ 10:
  168. /***/ (function(module, exports) {
  169. module.exports = require("element-ui/lib/utils/clickoutside");
  170. /***/ }),
  171. /***/ 11:
  172. /***/ (function(module, exports, __webpack_require__) {
  173. "use strict";
  174. exports.__esModule = true;
  175. exports.extractTimeFormat = exports.extractDateFormat = exports.nextYear = exports.prevYear = exports.nextMonth = exports.prevMonth = exports.changeYearMonthAndClampDate = exports.timeWithinRange = exports.limitTimeRange = exports.clearMilliseconds = exports.clearTime = exports.modifyWithTimeString = exports.modifyTime = exports.modifyDate = exports.range = exports.getRangeMinutes = exports.getRangeHours = exports.getWeekNumber = exports.getStartDateOfMonth = exports.nextDate = exports.prevDate = exports.getFirstDayOfMonth = exports.getDayCountOfYear = exports.getDayCountOfMonth = exports.parseDate = exports.formatDate = exports.isDateObject = exports.isDate = exports.toDate = undefined;
  176. var _date = __webpack_require__(29);
  177. var _date2 = _interopRequireDefault(_date);
  178. var _locale = __webpack_require__(12);
  179. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  180. var weeks = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
  181. var months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
  182. var getI18nSettings = function getI18nSettings() {
  183. return {
  184. dayNamesShort: weeks.map(function (week) {
  185. return (0, _locale.t)('el.datepicker.weeks.' + week);
  186. }),
  187. dayNames: weeks.map(function (week) {
  188. return (0, _locale.t)('el.datepicker.weeks.' + week);
  189. }),
  190. monthNamesShort: months.map(function (month) {
  191. return (0, _locale.t)('el.datepicker.months.' + month);
  192. }),
  193. monthNames: months.map(function (month, index) {
  194. return (0, _locale.t)('el.datepicker.month' + (index + 1));
  195. }),
  196. amPm: ['am', 'pm']
  197. };
  198. };
  199. var newArray = function newArray(start, end) {
  200. var result = [];
  201. for (var i = start; i <= end; i++) {
  202. result.push(i);
  203. }
  204. return result;
  205. };
  206. var toDate = exports.toDate = function toDate(date) {
  207. return isDate(date) ? new Date(date) : null;
  208. };
  209. var isDate = exports.isDate = function isDate(date) {
  210. if (date === null || date === undefined) return false;
  211. if (isNaN(new Date(date).getTime())) return false;
  212. if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
  213. return true;
  214. };
  215. var isDateObject = exports.isDateObject = function isDateObject(val) {
  216. return val instanceof Date;
  217. };
  218. var formatDate = exports.formatDate = function formatDate(date, format) {
  219. date = toDate(date);
  220. if (!date) return '';
  221. return _date2.default.format(date, format || 'yyyy-MM-dd', getI18nSettings());
  222. };
  223. var parseDate = exports.parseDate = function parseDate(string, format) {
  224. return _date2.default.parse(string, format || 'yyyy-MM-dd', getI18nSettings());
  225. };
  226. var getDayCountOfMonth = exports.getDayCountOfMonth = function getDayCountOfMonth(year, month) {
  227. if (month === 3 || month === 5 || month === 8 || month === 10) {
  228. return 30;
  229. }
  230. if (month === 1) {
  231. if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
  232. return 29;
  233. } else {
  234. return 28;
  235. }
  236. }
  237. return 31;
  238. };
  239. var getDayCountOfYear = exports.getDayCountOfYear = function getDayCountOfYear(year) {
  240. var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
  241. return isLeapYear ? 366 : 365;
  242. };
  243. var getFirstDayOfMonth = exports.getFirstDayOfMonth = function getFirstDayOfMonth(date) {
  244. var temp = new Date(date.getTime());
  245. temp.setDate(1);
  246. return temp.getDay();
  247. };
  248. // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
  249. // {prev, next} Date should work for Daylight Saving Time
  250. // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
  251. var prevDate = exports.prevDate = function prevDate(date) {
  252. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  253. return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
  254. };
  255. var nextDate = exports.nextDate = function nextDate(date) {
  256. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  257. return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
  258. };
  259. var getStartDateOfMonth = exports.getStartDateOfMonth = function getStartDateOfMonth(year, month) {
  260. var result = new Date(year, month, 1);
  261. var day = result.getDay();
  262. if (day === 0) {
  263. return prevDate(result, 7);
  264. } else {
  265. return prevDate(result, day);
  266. }
  267. };
  268. var getWeekNumber = exports.getWeekNumber = function getWeekNumber(src) {
  269. if (!isDate(src)) return null;
  270. var date = new Date(src.getTime());
  271. date.setHours(0, 0, 0, 0);
  272. // Thursday in current week decides the year.
  273. date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
  274. // January 4 is always in week 1.
  275. var week1 = new Date(date.getFullYear(), 0, 4);
  276. // Adjust to Thursday in week 1 and count number of weeks from date to week 1.
  277. // Rounding should be fine for Daylight Saving Time. Its shift should never be more than 12 hours.
  278. return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7);
  279. };
  280. var getRangeHours = exports.getRangeHours = function getRangeHours(ranges) {
  281. var hours = [];
  282. var disabledHours = [];
  283. (ranges || []).forEach(function (range) {
  284. var value = range.map(function (date) {
  285. return date.getHours();
  286. });
  287. disabledHours = disabledHours.concat(newArray(value[0], value[1]));
  288. });
  289. if (disabledHours.length) {
  290. for (var i = 0; i < 24; i++) {
  291. hours[i] = disabledHours.indexOf(i) === -1;
  292. }
  293. } else {
  294. for (var _i = 0; _i < 24; _i++) {
  295. hours[_i] = false;
  296. }
  297. }
  298. return hours;
  299. };
  300. function setRangeData(arr, start, end, value) {
  301. for (var i = start; i < end; i++) {
  302. arr[i] = value;
  303. }
  304. }
  305. var getRangeMinutes = exports.getRangeMinutes = function getRangeMinutes(ranges, hour) {
  306. var minutes = new Array(60);
  307. if (ranges.length > 0) {
  308. ranges.forEach(function (range) {
  309. var start = range[0];
  310. var end = range[1];
  311. var startHour = start.getHours();
  312. var startMinute = start.getMinutes();
  313. var endHour = end.getHours();
  314. var endMinute = end.getMinutes();
  315. if (startHour === hour && endHour !== hour) {
  316. setRangeData(minutes, startMinute, 60, true);
  317. } else if (startHour === hour && endHour === hour) {
  318. setRangeData(minutes, startMinute, endMinute + 1, true);
  319. } else if (startHour !== hour && endHour === hour) {
  320. setRangeData(minutes, 0, endMinute + 1, true);
  321. } else if (startHour < hour && endHour > hour) {
  322. setRangeData(minutes, 0, 60, true);
  323. }
  324. });
  325. } else {
  326. setRangeData(minutes, 0, 60, true);
  327. }
  328. return minutes;
  329. };
  330. var range = exports.range = function range(n) {
  331. // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
  332. return Array.apply(null, { length: n }).map(function (_, n) {
  333. return n;
  334. });
  335. };
  336. var modifyDate = exports.modifyDate = function modifyDate(date, y, m, d) {
  337. return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
  338. };
  339. var modifyTime = exports.modifyTime = function modifyTime(date, h, m, s) {
  340. return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
  341. };
  342. var modifyWithTimeString = exports.modifyWithTimeString = function modifyWithTimeString(date, time) {
  343. if (date == null || !time) {
  344. return date;
  345. }
  346. time = parseDate(time, 'HH:mm:ss');
  347. return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
  348. };
  349. var clearTime = exports.clearTime = function clearTime(date) {
  350. return new Date(date.getFullYear(), date.getMonth(), date.getDate());
  351. };
  352. var clearMilliseconds = exports.clearMilliseconds = function clearMilliseconds(date) {
  353. return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
  354. };
  355. var limitTimeRange = exports.limitTimeRange = function limitTimeRange(date, ranges) {
  356. var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
  357. // TODO: refactory a more elegant solution
  358. if (ranges.length === 0) return date;
  359. var normalizeDate = function normalizeDate(date) {
  360. return _date2.default.parse(_date2.default.format(date, format), format);
  361. };
  362. var ndate = normalizeDate(date);
  363. var nranges = ranges.map(function (range) {
  364. return range.map(normalizeDate);
  365. });
  366. if (nranges.some(function (nrange) {
  367. return ndate >= nrange[0] && ndate <= nrange[1];
  368. })) return date;
  369. var minDate = nranges[0][0];
  370. var maxDate = nranges[0][0];
  371. nranges.forEach(function (nrange) {
  372. minDate = new Date(Math.min(nrange[0], minDate));
  373. maxDate = new Date(Math.max(nrange[1], minDate));
  374. });
  375. var ret = ndate < minDate ? minDate : maxDate;
  376. // preserve Year/Month/Date
  377. return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
  378. };
  379. var timeWithinRange = exports.timeWithinRange = function timeWithinRange(date, selectableRange, format) {
  380. var limitedDate = limitTimeRange(date, selectableRange, format);
  381. return limitedDate.getTime() === date.getTime();
  382. };
  383. var changeYearMonthAndClampDate = exports.changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
  384. // clamp date to the number of days in `year`, `month`
  385. // eg: (2010-1-31, 2010, 2) => 2010-2-28
  386. var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
  387. return modifyDate(date, year, month, monthDate);
  388. };
  389. var prevMonth = exports.prevMonth = function prevMonth(date) {
  390. var year = date.getFullYear();
  391. var month = date.getMonth();
  392. return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
  393. };
  394. var nextMonth = exports.nextMonth = function nextMonth(date) {
  395. var year = date.getFullYear();
  396. var month = date.getMonth();
  397. return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
  398. };
  399. var prevYear = exports.prevYear = function prevYear(date) {
  400. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  401. var year = date.getFullYear();
  402. var month = date.getMonth();
  403. return changeYearMonthAndClampDate(date, year - amount, month);
  404. };
  405. var nextYear = exports.nextYear = function nextYear(date) {
  406. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  407. var year = date.getFullYear();
  408. var month = date.getMonth();
  409. return changeYearMonthAndClampDate(date, year + amount, month);
  410. };
  411. var extractDateFormat = exports.extractDateFormat = function extractDateFormat(format) {
  412. return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
  413. };
  414. var extractTimeFormat = exports.extractTimeFormat = function extractTimeFormat(format) {
  415. return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
  416. };
  417. /***/ }),
  418. /***/ 12:
  419. /***/ (function(module, exports) {
  420. module.exports = require("element-ui/lib/locale");
  421. /***/ }),
  422. /***/ 15:
  423. /***/ (function(module, exports) {
  424. module.exports = require("element-ui/lib/button");
  425. /***/ }),
  426. /***/ 17:
  427. /***/ (function(module, exports) {
  428. module.exports = require("element-ui/lib/scrollbar");
  429. /***/ }),
  430. /***/ 176:
  431. /***/ (function(module, exports, __webpack_require__) {
  432. "use strict";
  433. exports.__esModule = true;
  434. var _datePicker = __webpack_require__(177);
  435. var _datePicker2 = _interopRequireDefault(_datePicker);
  436. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  437. /* istanbul ignore next */
  438. _datePicker2.default.install = function install(Vue) {
  439. Vue.component(_datePicker2.default.name, _datePicker2.default);
  440. };
  441. exports.default = _datePicker2.default;
  442. /***/ }),
  443. /***/ 177:
  444. /***/ (function(module, exports, __webpack_require__) {
  445. "use strict";
  446. exports.__esModule = true;
  447. var _picker = __webpack_require__(27);
  448. var _picker2 = _interopRequireDefault(_picker);
  449. var _date = __webpack_require__(178);
  450. var _date2 = _interopRequireDefault(_date);
  451. var _dateRange = __webpack_require__(189);
  452. var _dateRange2 = _interopRequireDefault(_dateRange);
  453. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  454. var getPanel = function getPanel(type) {
  455. if (type === 'daterange' || type === 'datetimerange') {
  456. return _dateRange2.default;
  457. }
  458. return _date2.default;
  459. };
  460. exports.default = {
  461. mixins: [_picker2.default],
  462. name: 'ElDatePicker',
  463. props: {
  464. type: {
  465. type: String,
  466. default: 'date'
  467. },
  468. timeArrowControl: Boolean
  469. },
  470. watch: {
  471. type: function type(_type) {
  472. if (this.picker) {
  473. this.unmountPicker();
  474. this.panel = getPanel(_type);
  475. this.mountPicker();
  476. } else {
  477. this.panel = getPanel(_type);
  478. }
  479. }
  480. },
  481. created: function created() {
  482. this.panel = getPanel(this.type);
  483. }
  484. };
  485. /***/ }),
  486. /***/ 178:
  487. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  488. "use strict";
  489. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  490. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_date_vue__ = __webpack_require__(179);
  491. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_date_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_date_vue__);
  492. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_2555bb87_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_date_vue__ = __webpack_require__(188);
  493. var normalizeComponent = __webpack_require__(0)
  494. /* script */
  495. /* template */
  496. /* template functional */
  497. var __vue_template_functional__ = false
  498. /* styles */
  499. var __vue_styles__ = null
  500. /* scopeId */
  501. var __vue_scopeId__ = null
  502. /* moduleIdentifier (server only) */
  503. var __vue_module_identifier__ = null
  504. var Component = normalizeComponent(
  505. __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_date_vue___default.a,
  506. __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_2555bb87_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_date_vue__["a" /* default */],
  507. __vue_template_functional__,
  508. __vue_styles__,
  509. __vue_scopeId__,
  510. __vue_module_identifier__
  511. )
  512. /* harmony default export */ __webpack_exports__["default"] = (Component.exports);
  513. /***/ }),
  514. /***/ 179:
  515. /***/ (function(module, exports, __webpack_require__) {
  516. "use strict";
  517. exports.__esModule = true;
  518. var _util = __webpack_require__(11);
  519. var _clickoutside = __webpack_require__(10);
  520. var _clickoutside2 = _interopRequireDefault(_clickoutside);
  521. var _locale = __webpack_require__(5);
  522. var _locale2 = _interopRequireDefault(_locale);
  523. var _input = __webpack_require__(6);
  524. var _input2 = _interopRequireDefault(_input);
  525. var _button = __webpack_require__(15);
  526. var _button2 = _interopRequireDefault(_button);
  527. var _time = __webpack_require__(31);
  528. var _time2 = _interopRequireDefault(_time);
  529. var _yearTable = __webpack_require__(180);
  530. var _yearTable2 = _interopRequireDefault(_yearTable);
  531. var _monthTable = __webpack_require__(183);
  532. var _monthTable2 = _interopRequireDefault(_monthTable);
  533. var _dateTable = __webpack_require__(49);
  534. var _dateTable2 = _interopRequireDefault(_dateTable);
  535. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  536. exports.default = {
  537. mixins: [_locale2.default],
  538. directives: { Clickoutside: _clickoutside2.default },
  539. watch: {
  540. showTime: function showTime(val) {
  541. var _this = this;
  542. /* istanbul ignore if */
  543. if (!val) return;
  544. this.$nextTick(function (_) {
  545. var inputElm = _this.$refs.input.$el;
  546. if (inputElm) {
  547. _this.pickerWidth = inputElm.getBoundingClientRect().width + 10;
  548. }
  549. });
  550. },
  551. value: function value(val) {
  552. if (this.selectionMode === 'dates' && this.value) return;
  553. if ((0, _util.isDate)(val)) {
  554. this.date = new Date(val);
  555. } else {
  556. this.date = this.getDefaultValue();
  557. }
  558. },
  559. defaultValue: function defaultValue(val) {
  560. if (!(0, _util.isDate)(this.value)) {
  561. this.date = val ? new Date(val) : new Date();
  562. }
  563. },
  564. timePickerVisible: function timePickerVisible(val) {
  565. var _this2 = this;
  566. if (val) this.$nextTick(function () {
  567. return _this2.$refs.timepicker.adjustSpinners();
  568. });
  569. },
  570. selectionMode: function selectionMode(newVal) {
  571. if (newVal === 'month') {
  572. /* istanbul ignore next */
  573. if (this.currentView !== 'year' || this.currentView !== 'month') {
  574. this.currentView = 'month';
  575. }
  576. } else if (newVal === 'dates') {
  577. this.currentView = 'date';
  578. }
  579. }
  580. },
  581. methods: {
  582. proxyTimePickerDataProperties: function proxyTimePickerDataProperties() {
  583. var _this3 = this;
  584. var format = function format(timeFormat) {
  585. _this3.$refs.timepicker.format = timeFormat;
  586. };
  587. var value = function value(_value) {
  588. _this3.$refs.timepicker.value = _value;
  589. };
  590. var date = function date(_date) {
  591. _this3.$refs.timepicker.date = _date;
  592. };
  593. this.$watch('value', value);
  594. this.$watch('date', date);
  595. format(this.timeFormat);
  596. value(this.value);
  597. date(this.date);
  598. },
  599. handleClear: function handleClear() {
  600. this.date = this.getDefaultValue();
  601. this.$emit('pick', null);
  602. },
  603. emit: function emit(value) {
  604. var _this4 = this;
  605. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  606. args[_key - 1] = arguments[_key];
  607. }
  608. if (!value) {
  609. this.$emit.apply(this, ['pick', value].concat(args));
  610. } else if (Array.isArray(value)) {
  611. var dates = value.map(function (date) {
  612. return _this4.showTime ? (0, _util.clearMilliseconds)(date) : (0, _util.clearTime)(date);
  613. });
  614. this.$emit.apply(this, ['pick', dates].concat(args));
  615. } else {
  616. this.$emit.apply(this, ['pick', this.showTime ? (0, _util.clearMilliseconds)(value) : (0, _util.clearTime)(value)].concat(args));
  617. }
  618. this.userInputDate = null;
  619. this.userInputTime = null;
  620. },
  621. // resetDate() {
  622. // this.date = new Date(this.date);
  623. // },
  624. showMonthPicker: function showMonthPicker() {
  625. this.currentView = 'month';
  626. },
  627. showYearPicker: function showYearPicker() {
  628. this.currentView = 'year';
  629. },
  630. // XXX: 没用到
  631. // handleLabelClick() {
  632. // if (this.currentView === 'date') {
  633. // this.showMonthPicker();
  634. // } else if (this.currentView === 'month') {
  635. // this.showYearPicker();
  636. // }
  637. // },
  638. prevMonth: function prevMonth() {
  639. this.date = (0, _util.prevMonth)(this.date);
  640. },
  641. nextMonth: function nextMonth() {
  642. this.date = (0, _util.nextMonth)(this.date);
  643. },
  644. prevYear: function prevYear() {
  645. if (this.currentView === 'year') {
  646. this.date = (0, _util.prevYear)(this.date, 10);
  647. } else {
  648. this.date = (0, _util.prevYear)(this.date);
  649. }
  650. },
  651. nextYear: function nextYear() {
  652. if (this.currentView === 'year') {
  653. this.date = (0, _util.nextYear)(this.date, 10);
  654. } else {
  655. this.date = (0, _util.nextYear)(this.date);
  656. }
  657. },
  658. handleShortcutClick: function handleShortcutClick(shortcut) {
  659. if (shortcut.onClick) {
  660. shortcut.onClick(this);
  661. }
  662. },
  663. handleTimePick: function handleTimePick(value, visible, first) {
  664. if ((0, _util.isDate)(value)) {
  665. var newDate = this.value ? (0, _util.modifyTime)(this.value, value.getHours(), value.getMinutes(), value.getSeconds()) : (0, _util.modifyWithTimeString)(this.getDefaultValue(), this.defaultTime);
  666. this.date = newDate;
  667. this.emit(this.date, true);
  668. } else {
  669. this.emit(value, true);
  670. }
  671. if (!first) {
  672. this.timePickerVisible = visible;
  673. }
  674. },
  675. handleTimePickClose: function handleTimePickClose() {
  676. this.timePickerVisible = false;
  677. },
  678. handleMonthPick: function handleMonthPick(month) {
  679. if (this.selectionMode === 'month') {
  680. this.date = (0, _util.modifyDate)(this.date, this.year, month, 1);
  681. this.emit(this.date);
  682. } else {
  683. this.date = (0, _util.changeYearMonthAndClampDate)(this.date, this.year, month);
  684. // TODO: should emit intermediate value ??
  685. // this.emit(this.date);
  686. this.currentView = 'date';
  687. }
  688. },
  689. handleDatePick: function handleDatePick(value) {
  690. if (this.selectionMode === 'day') {
  691. this.date = this.value ? (0, _util.modifyDate)(this.value, value.getFullYear(), value.getMonth(), value.getDate()) : (0, _util.modifyWithTimeString)(value, this.defaultTime);
  692. this.emit(this.date, this.showTime);
  693. } else if (this.selectionMode === 'week') {
  694. this.emit(value.date);
  695. } else if (this.selectionMode === 'dates') {
  696. this.emit(value, true); // set false to keep panel open
  697. }
  698. },
  699. handleYearPick: function handleYearPick(year) {
  700. if (this.selectionMode === 'year') {
  701. this.date = (0, _util.modifyDate)(this.date, year, 0, 1);
  702. this.emit(this.date);
  703. } else {
  704. this.date = (0, _util.changeYearMonthAndClampDate)(this.date, year, this.month);
  705. // TODO: should emit intermediate value ??
  706. // this.emit(this.date, true);
  707. this.currentView = 'month';
  708. }
  709. },
  710. changeToNow: function changeToNow() {
  711. // NOTE: not a permanent solution
  712. // consider disable "now" button in the future
  713. if (!this.disabledDate || !this.disabledDate(new Date())) {
  714. this.date = new Date();
  715. this.emit(this.date);
  716. }
  717. },
  718. confirm: function confirm() {
  719. if (this.selectionMode === 'dates') {
  720. this.emit(this.value);
  721. } else {
  722. // value were emitted in handle{Date,Time}Pick, nothing to update here
  723. // deal with the scenario where: user opens the picker, then confirm without doing anything
  724. var value = this.value ? this.value : (0, _util.modifyWithTimeString)(this.getDefaultValue(), this.defaultTime);
  725. this.date = new Date(value); // refresh date
  726. this.emit(value);
  727. }
  728. },
  729. resetView: function resetView() {
  730. if (this.selectionMode === 'month') {
  731. this.currentView = 'month';
  732. } else if (this.selectionMode === 'year') {
  733. this.currentView = 'year';
  734. } else {
  735. this.currentView = 'date';
  736. }
  737. },
  738. handleEnter: function handleEnter() {
  739. document.body.addEventListener('keydown', this.handleKeydown);
  740. },
  741. handleLeave: function handleLeave() {
  742. this.$emit('dodestroy');
  743. document.body.removeEventListener('keydown', this.handleKeydown);
  744. },
  745. handleKeydown: function handleKeydown(event) {
  746. var keyCode = event.keyCode;
  747. var list = [38, 40, 37, 39];
  748. if (this.visible && !this.timePickerVisible) {
  749. if (list.indexOf(keyCode) !== -1) {
  750. this.handleKeyControl(keyCode);
  751. event.stopPropagation();
  752. event.preventDefault();
  753. }
  754. if (keyCode === 13 && this.userInputDate === null && this.userInputTime === null) {
  755. // Enter
  756. this.emit(this.date, false);
  757. }
  758. }
  759. },
  760. handleKeyControl: function handleKeyControl(keyCode) {
  761. var mapping = {
  762. 'year': {
  763. 38: -4, 40: 4, 37: -1, 39: 1, offset: function offset(date, step) {
  764. return date.setFullYear(date.getFullYear() + step);
  765. }
  766. },
  767. 'month': {
  768. 38: -4, 40: 4, 37: -1, 39: 1, offset: function offset(date, step) {
  769. return date.setMonth(date.getMonth() + step);
  770. }
  771. },
  772. 'week': {
  773. 38: -1, 40: 1, 37: -1, 39: 1, offset: function offset(date, step) {
  774. return date.setDate(date.getDate() + step * 7);
  775. }
  776. },
  777. 'day': {
  778. 38: -7, 40: 7, 37: -1, 39: 1, offset: function offset(date, step) {
  779. return date.setDate(date.getDate() + step);
  780. }
  781. }
  782. };
  783. var mode = this.selectionMode;
  784. var year = 3.1536e10;
  785. var now = this.date.getTime();
  786. var newDate = new Date(this.date.getTime());
  787. while (Math.abs(now - newDate.getTime()) <= year) {
  788. var map = mapping[mode];
  789. map.offset(newDate, map[keyCode]);
  790. if (typeof this.disabledDate === 'function' && this.disabledDate(newDate)) {
  791. continue;
  792. }
  793. this.date = newDate;
  794. this.$emit('pick', newDate, true);
  795. break;
  796. }
  797. },
  798. handleVisibleTimeChange: function handleVisibleTimeChange(value) {
  799. var time = (0, _util.parseDate)(value, this.timeFormat);
  800. if (time) {
  801. this.date = (0, _util.modifyDate)(time, this.year, this.month, this.monthDate);
  802. this.userInputTime = null;
  803. this.$refs.timepicker.value = this.date;
  804. this.timePickerVisible = false;
  805. this.emit(this.date, true);
  806. }
  807. },
  808. handleVisibleDateChange: function handleVisibleDateChange(value) {
  809. var date = (0, _util.parseDate)(value, this.dateFormat);
  810. if (date) {
  811. if (typeof this.disabledDate === 'function' && this.disabledDate(date)) {
  812. return;
  813. }
  814. this.date = (0, _util.modifyTime)(date, this.date.getHours(), this.date.getMinutes(), this.date.getSeconds());
  815. this.userInputDate = null;
  816. this.resetView();
  817. this.emit(this.date, true);
  818. }
  819. },
  820. isValidValue: function isValidValue(value) {
  821. return value && !isNaN(value) && (typeof this.disabledDate === 'function' ? !this.disabledDate(value) : true);
  822. },
  823. getDefaultValue: function getDefaultValue() {
  824. // if default-value is set, return it
  825. // otherwise, return now (the moment this method gets called)
  826. return this.defaultValue ? new Date(this.defaultValue) : new Date();
  827. }
  828. },
  829. components: {
  830. TimePicker: _time2.default, YearTable: _yearTable2.default, MonthTable: _monthTable2.default, DateTable: _dateTable2.default, ElInput: _input2.default, ElButton: _button2.default
  831. },
  832. data: function data() {
  833. return {
  834. popperClass: '',
  835. date: new Date(),
  836. value: '',
  837. defaultValue: null, // use getDefaultValue() for time computation
  838. defaultTime: null,
  839. showTime: false,
  840. selectionMode: 'day',
  841. shortcuts: '',
  842. visible: false,
  843. currentView: 'date',
  844. disabledDate: '',
  845. firstDayOfWeek: 7,
  846. showWeekNumber: false,
  847. timePickerVisible: false,
  848. format: '',
  849. arrowControl: false,
  850. userInputDate: null,
  851. userInputTime: null
  852. };
  853. },
  854. computed: {
  855. year: function year() {
  856. return this.date.getFullYear();
  857. },
  858. month: function month() {
  859. return this.date.getMonth();
  860. },
  861. week: function week() {
  862. return (0, _util.getWeekNumber)(this.date);
  863. },
  864. monthDate: function monthDate() {
  865. return this.date.getDate();
  866. },
  867. footerVisible: function footerVisible() {
  868. return this.showTime || this.selectionMode === 'dates';
  869. },
  870. visibleTime: function visibleTime() {
  871. if (this.userInputTime !== null) {
  872. return this.userInputTime;
  873. } else {
  874. return (0, _util.formatDate)(this.value || this.defaultValue, this.timeFormat);
  875. }
  876. },
  877. visibleDate: function visibleDate() {
  878. if (this.userInputDate !== null) {
  879. return this.userInputDate;
  880. } else {
  881. return (0, _util.formatDate)(this.value || this.defaultValue, this.dateFormat);
  882. }
  883. },
  884. yearLabel: function yearLabel() {
  885. var yearTranslation = this.t('el.datepicker.year');
  886. if (this.currentView === 'year') {
  887. var startYear = Math.floor(this.year / 10) * 10;
  888. if (yearTranslation) {
  889. return startYear + ' ' + yearTranslation + ' - ' + (startYear + 9) + ' ' + yearTranslation;
  890. }
  891. return startYear + ' - ' + (startYear + 9);
  892. }
  893. return this.year + ' ' + yearTranslation;
  894. },
  895. timeFormat: function timeFormat() {
  896. if (this.format) {
  897. return (0, _util.extractTimeFormat)(this.format);
  898. } else {
  899. return 'HH:mm:ss';
  900. }
  901. },
  902. dateFormat: function dateFormat() {
  903. if (this.format) {
  904. return (0, _util.extractDateFormat)(this.format);
  905. } else {
  906. return 'yyyy-MM-dd';
  907. }
  908. }
  909. }
  910. }; //
  911. //
  912. //
  913. //
  914. //
  915. //
  916. //
  917. //
  918. //
  919. //
  920. //
  921. //
  922. //
  923. //
  924. //
  925. //
  926. //
  927. //
  928. //
  929. //
  930. //
  931. //
  932. //
  933. //
  934. //
  935. //
  936. //
  937. //
  938. //
  939. //
  940. //
  941. //
  942. //
  943. //
  944. //
  945. //
  946. //
  947. //
  948. //
  949. //
  950. //
  951. //
  952. //
  953. //
  954. //
  955. //
  956. //
  957. //
  958. //
  959. //
  960. //
  961. //
  962. //
  963. //
  964. //
  965. //
  966. //
  967. //
  968. //
  969. //
  970. //
  971. //
  972. //
  973. //
  974. //
  975. //
  976. //
  977. //
  978. //
  979. //
  980. //
  981. //
  982. //
  983. //
  984. //
  985. //
  986. //
  987. //
  988. //
  989. //
  990. //
  991. //
  992. //
  993. //
  994. //
  995. //
  996. //
  997. //
  998. //
  999. //
  1000. //
  1001. //
  1002. //
  1003. //
  1004. //
  1005. //
  1006. //
  1007. //
  1008. //
  1009. //
  1010. //
  1011. //
  1012. //
  1013. //
  1014. //
  1015. //
  1016. //
  1017. //
  1018. //
  1019. //
  1020. //
  1021. //
  1022. //
  1023. //
  1024. //
  1025. //
  1026. //
  1027. //
  1028. //
  1029. //
  1030. //
  1031. //
  1032. //
  1033. //
  1034. //
  1035. //
  1036. //
  1037. //
  1038. //
  1039. //
  1040. //
  1041. //
  1042. //
  1043. //
  1044. //
  1045. //
  1046. //
  1047. //
  1048. //
  1049. //
  1050. //
  1051. //
  1052. //
  1053. /***/ }),
  1054. /***/ 180:
  1055. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1056. "use strict";
  1057. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  1058. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_year_table_vue__ = __webpack_require__(181);
  1059. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_year_table_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_year_table_vue__);
  1060. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_6f653c26_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_year_table_vue__ = __webpack_require__(182);
  1061. var normalizeComponent = __webpack_require__(0)
  1062. /* script */
  1063. /* template */
  1064. /* template functional */
  1065. var __vue_template_functional__ = false
  1066. /* styles */
  1067. var __vue_styles__ = null
  1068. /* scopeId */
  1069. var __vue_scopeId__ = null
  1070. /* moduleIdentifier (server only) */
  1071. var __vue_module_identifier__ = null
  1072. var Component = normalizeComponent(
  1073. __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_year_table_vue___default.a,
  1074. __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_6f653c26_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_year_table_vue__["a" /* default */],
  1075. __vue_template_functional__,
  1076. __vue_styles__,
  1077. __vue_scopeId__,
  1078. __vue_module_identifier__
  1079. )
  1080. /* harmony default export */ __webpack_exports__["default"] = (Component.exports);
  1081. /***/ }),
  1082. /***/ 181:
  1083. /***/ (function(module, exports, __webpack_require__) {
  1084. "use strict";
  1085. exports.__esModule = true;
  1086. var _dom = __webpack_require__(3);
  1087. var _util = __webpack_require__(11);
  1088. var _util2 = __webpack_require__(2);
  1089. var datesInYear = function datesInYear(year) {
  1090. var numOfDays = (0, _util.getDayCountOfYear)(year);
  1091. var firstDay = new Date(year, 0, 1);
  1092. return (0, _util.range)(numOfDays).map(function (n) {
  1093. return (0, _util.nextDate)(firstDay, n);
  1094. });
  1095. }; //
  1096. //
  1097. //
  1098. //
  1099. //
  1100. //
  1101. //
  1102. //
  1103. //
  1104. //
  1105. //
  1106. //
  1107. //
  1108. //
  1109. //
  1110. //
  1111. //
  1112. //
  1113. //
  1114. //
  1115. //
  1116. //
  1117. //
  1118. //
  1119. //
  1120. //
  1121. //
  1122. //
  1123. //
  1124. //
  1125. //
  1126. //
  1127. //
  1128. //
  1129. //
  1130. //
  1131. //
  1132. //
  1133. //
  1134. //
  1135. //
  1136. //
  1137. //
  1138. //
  1139. //
  1140. exports.default = {
  1141. props: {
  1142. disabledDate: {},
  1143. value: {},
  1144. defaultValue: {
  1145. validator: function validator(val) {
  1146. // null or valid Date Object
  1147. return val === null || val instanceof Date && (0, _util.isDate)(val);
  1148. }
  1149. },
  1150. date: {}
  1151. },
  1152. computed: {
  1153. startYear: function startYear() {
  1154. return Math.floor(this.date.getFullYear() / 10) * 10;
  1155. }
  1156. },
  1157. methods: {
  1158. getCellStyle: function getCellStyle(year) {
  1159. var style = {};
  1160. var today = new Date();
  1161. style.disabled = typeof this.disabledDate === 'function' ? datesInYear(year).every(this.disabledDate) : false;
  1162. style.current = (0, _util2.arrayFindIndex)((0, _util2.coerceTruthyValueToArray)(this.value), function (date) {
  1163. return date.getFullYear() === year;
  1164. }) >= 0;
  1165. style.today = today.getFullYear() === year;
  1166. style.default = this.defaultValue && this.defaultValue.getFullYear() === year;
  1167. return style;
  1168. },
  1169. handleYearTableClick: function handleYearTableClick(event) {
  1170. var target = event.target;
  1171. if (target.tagName === 'A') {
  1172. if ((0, _dom.hasClass)(target.parentNode, 'disabled')) return;
  1173. var year = target.textContent || target.innerText;
  1174. this.$emit('pick', Number(year));
  1175. }
  1176. }
  1177. }
  1178. };
  1179. /***/ }),
  1180. /***/ 182:
  1181. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1182. "use strict";
  1183. var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('table',{staticClass:"el-year-table",on:{"click":_vm.handleYearTableClick}},[_c('tbody',[_c('tr',[_c('td',{staticClass:"available",class:_vm.getCellStyle(_vm.startYear + 0)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.startYear))])]),_c('td',{staticClass:"available",class:_vm.getCellStyle(_vm.startYear + 1)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.startYear + 1))])]),_c('td',{staticClass:"available",class:_vm.getCellStyle(_vm.startYear + 2)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.startYear + 2))])]),_c('td',{staticClass:"available",class:_vm.getCellStyle(_vm.startYear + 3)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.startYear + 3))])])]),_c('tr',[_c('td',{staticClass:"available",class:_vm.getCellStyle(_vm.startYear + 4)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.startYear + 4))])]),_c('td',{staticClass:"available",class:_vm.getCellStyle(_vm.startYear + 5)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.startYear + 5))])]),_c('td',{staticClass:"available",class:_vm.getCellStyle(_vm.startYear + 6)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.startYear + 6))])]),_c('td',{staticClass:"available",class:_vm.getCellStyle(_vm.startYear + 7)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.startYear + 7))])])]),_c('tr',[_c('td',{staticClass:"available",class:_vm.getCellStyle(_vm.startYear + 8)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.startYear + 8))])]),_c('td',{staticClass:"available",class:_vm.getCellStyle(_vm.startYear + 9)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.startYear + 9))])]),_c('td'),_c('td')])])])}
  1184. var staticRenderFns = []
  1185. var esExports = { render: render, staticRenderFns: staticRenderFns }
  1186. /* harmony default export */ __webpack_exports__["a"] = (esExports);
  1187. /***/ }),
  1188. /***/ 183:
  1189. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1190. "use strict";
  1191. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  1192. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_month_table_vue__ = __webpack_require__(184);
  1193. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_month_table_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_month_table_vue__);
  1194. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_312e3722_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_month_table_vue__ = __webpack_require__(185);
  1195. var normalizeComponent = __webpack_require__(0)
  1196. /* script */
  1197. /* template */
  1198. /* template functional */
  1199. var __vue_template_functional__ = false
  1200. /* styles */
  1201. var __vue_styles__ = null
  1202. /* scopeId */
  1203. var __vue_scopeId__ = null
  1204. /* moduleIdentifier (server only) */
  1205. var __vue_module_identifier__ = null
  1206. var Component = normalizeComponent(
  1207. __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_month_table_vue___default.a,
  1208. __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_312e3722_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_month_table_vue__["a" /* default */],
  1209. __vue_template_functional__,
  1210. __vue_styles__,
  1211. __vue_scopeId__,
  1212. __vue_module_identifier__
  1213. )
  1214. /* harmony default export */ __webpack_exports__["default"] = (Component.exports);
  1215. /***/ }),
  1216. /***/ 184:
  1217. /***/ (function(module, exports, __webpack_require__) {
  1218. "use strict";
  1219. exports.__esModule = true;
  1220. var _locale = __webpack_require__(5);
  1221. var _locale2 = _interopRequireDefault(_locale);
  1222. var _util = __webpack_require__(11);
  1223. var _dom = __webpack_require__(3);
  1224. var _util2 = __webpack_require__(2);
  1225. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1226. //
  1227. //
  1228. //
  1229. //
  1230. //
  1231. //
  1232. //
  1233. //
  1234. //
  1235. //
  1236. //
  1237. //
  1238. //
  1239. //
  1240. //
  1241. //
  1242. //
  1243. //
  1244. //
  1245. //
  1246. //
  1247. //
  1248. //
  1249. //
  1250. //
  1251. //
  1252. //
  1253. //
  1254. //
  1255. //
  1256. //
  1257. //
  1258. //
  1259. //
  1260. //
  1261. //
  1262. //
  1263. //
  1264. //
  1265. //
  1266. //
  1267. //
  1268. //
  1269. //
  1270. //
  1271. //
  1272. //
  1273. //
  1274. //
  1275. var datesInMonth = function datesInMonth(year, month) {
  1276. var numOfDays = (0, _util.getDayCountOfMonth)(year, month);
  1277. var firstDay = new Date(year, month, 1);
  1278. return (0, _util.range)(numOfDays).map(function (n) {
  1279. return (0, _util.nextDate)(firstDay, n);
  1280. });
  1281. };
  1282. exports.default = {
  1283. props: {
  1284. disabledDate: {},
  1285. value: {},
  1286. defaultValue: {
  1287. validator: function validator(val) {
  1288. // null or valid Date Object
  1289. return val === null || val instanceof Date && (0, _util.isDate)(val);
  1290. }
  1291. },
  1292. date: {}
  1293. },
  1294. mixins: [_locale2.default],
  1295. methods: {
  1296. getCellStyle: function getCellStyle(month) {
  1297. var style = {};
  1298. var year = this.date.getFullYear();
  1299. var today = new Date();
  1300. style.disabled = typeof this.disabledDate === 'function' ? datesInMonth(year, month).every(this.disabledDate) : false;
  1301. style.current = (0, _util2.arrayFindIndex)((0, _util2.coerceTruthyValueToArray)(this.value), function (date) {
  1302. return date.getFullYear() === year && date.getMonth() === month;
  1303. }) >= 0;
  1304. style.today = today.getFullYear() === year && today.getMonth() === month;
  1305. style.default = this.defaultValue && this.defaultValue.getFullYear() === year && this.defaultValue.getMonth() === month;
  1306. return style;
  1307. },
  1308. handleMonthTableClick: function handleMonthTableClick(event) {
  1309. var target = event.target;
  1310. if (target.tagName !== 'A') return;
  1311. if ((0, _dom.hasClass)(target.parentNode, 'disabled')) return;
  1312. var column = target.parentNode.cellIndex;
  1313. var row = target.parentNode.parentNode.rowIndex;
  1314. var month = row * 4 + column;
  1315. this.$emit('pick', month);
  1316. }
  1317. }
  1318. };
  1319. /***/ }),
  1320. /***/ 185:
  1321. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1322. "use strict";
  1323. var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('table',{staticClass:"el-month-table",on:{"click":_vm.handleMonthTableClick}},[_c('tbody',[_c('tr',[_c('td',{class:_vm.getCellStyle(0)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.t('el.datepicker.months.jan')))])]),_c('td',{class:_vm.getCellStyle(1)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.t('el.datepicker.months.feb')))])]),_c('td',{class:_vm.getCellStyle(2)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.t('el.datepicker.months.mar')))])]),_c('td',{class:_vm.getCellStyle(3)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.t('el.datepicker.months.apr')))])])]),_c('tr',[_c('td',{class:_vm.getCellStyle(4)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.t('el.datepicker.months.may')))])]),_c('td',{class:_vm.getCellStyle(5)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.t('el.datepicker.months.jun')))])]),_c('td',{class:_vm.getCellStyle(6)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.t('el.datepicker.months.jul')))])]),_c('td',{class:_vm.getCellStyle(7)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.t('el.datepicker.months.aug')))])])]),_c('tr',[_c('td',{class:_vm.getCellStyle(8)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.t('el.datepicker.months.sep')))])]),_c('td',{class:_vm.getCellStyle(9)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.t('el.datepicker.months.oct')))])]),_c('td',{class:_vm.getCellStyle(10)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.t('el.datepicker.months.nov')))])]),_c('td',{class:_vm.getCellStyle(11)},[_c('a',{staticClass:"cell"},[_vm._v(_vm._s(_vm.t('el.datepicker.months.dec')))])])])])])}
  1324. var staticRenderFns = []
  1325. var esExports = { render: render, staticRenderFns: staticRenderFns }
  1326. /* harmony default export */ __webpack_exports__["a"] = (esExports);
  1327. /***/ }),
  1328. /***/ 186:
  1329. /***/ (function(module, exports, __webpack_require__) {
  1330. "use strict";
  1331. exports.__esModule = true;
  1332. var _util = __webpack_require__(11);
  1333. var _locale = __webpack_require__(5);
  1334. var _locale2 = _interopRequireDefault(_locale);
  1335. var _util2 = __webpack_require__(2);
  1336. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1337. var _WEEKS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']; //
  1338. //
  1339. //
  1340. //
  1341. //
  1342. //
  1343. //
  1344. //
  1345. //
  1346. //
  1347. //
  1348. //
  1349. //
  1350. //
  1351. //
  1352. //
  1353. //
  1354. //
  1355. //
  1356. //
  1357. //
  1358. //
  1359. //
  1360. //
  1361. //
  1362. //
  1363. //
  1364. //
  1365. //
  1366. //
  1367. //
  1368. //
  1369. //
  1370. var getDateTimestamp = function getDateTimestamp(time) {
  1371. if (typeof time === 'number' || typeof time === 'string') {
  1372. return (0, _util.clearTime)(new Date(time)).getTime();
  1373. } else if (time instanceof Date) {
  1374. return (0, _util.clearTime)(time).getTime();
  1375. } else {
  1376. return NaN;
  1377. }
  1378. };
  1379. // remove the first element that satisfies `pred` from arr
  1380. // return a new array if modification occurs
  1381. // return the original array otherwise
  1382. var removeFromArray = function removeFromArray(arr, pred) {
  1383. var idx = typeof pred === 'function' ? (0, _util2.arrayFindIndex)(arr, pred) : arr.indexOf(pred);
  1384. return idx >= 0 ? [].concat(arr.slice(0, idx), arr.slice(idx + 1)) : arr;
  1385. };
  1386. exports.default = {
  1387. mixins: [_locale2.default],
  1388. props: {
  1389. firstDayOfWeek: {
  1390. default: 7,
  1391. type: Number,
  1392. validator: function validator(val) {
  1393. return val >= 1 && val <= 7;
  1394. }
  1395. },
  1396. value: {},
  1397. defaultValue: {
  1398. validator: function validator(val) {
  1399. // either: null, valid Date object, Array of valid Date objects
  1400. return val === null || (0, _util.isDate)(val) || Array.isArray(val) && val.every(_util.isDate);
  1401. }
  1402. },
  1403. date: {},
  1404. selectionMode: {
  1405. default: 'day'
  1406. },
  1407. showWeekNumber: {
  1408. type: Boolean,
  1409. default: false
  1410. },
  1411. disabledDate: {},
  1412. minDate: {},
  1413. maxDate: {},
  1414. rangeState: {
  1415. default: function _default() {
  1416. return {
  1417. endDate: null,
  1418. selecting: false
  1419. };
  1420. }
  1421. }
  1422. },
  1423. computed: {
  1424. offsetDay: function offsetDay() {
  1425. var week = this.firstDayOfWeek;
  1426. // 周日为界限,左右偏移的天数,3217654 例如周一就是 -1,目的是调整前两行日期的位置
  1427. return week > 3 ? 7 - week : -week;
  1428. },
  1429. WEEKS: function WEEKS() {
  1430. var week = this.firstDayOfWeek;
  1431. return _WEEKS.concat(_WEEKS).slice(week, week + 7);
  1432. },
  1433. year: function year() {
  1434. return this.date.getFullYear();
  1435. },
  1436. month: function month() {
  1437. return this.date.getMonth();
  1438. },
  1439. startDate: function startDate() {
  1440. return (0, _util.getStartDateOfMonth)(this.year, this.month);
  1441. },
  1442. rows: function rows() {
  1443. var _this = this;
  1444. // TODO: refactory rows / getCellClasses
  1445. var date = new Date(this.year, this.month, 1);
  1446. var day = (0, _util.getFirstDayOfMonth)(date); // day of first day
  1447. var dateCountOfMonth = (0, _util.getDayCountOfMonth)(date.getFullYear(), date.getMonth());
  1448. var dateCountOfLastMonth = (0, _util.getDayCountOfMonth)(date.getFullYear(), date.getMonth() === 0 ? 11 : date.getMonth() - 1);
  1449. day = day === 0 ? 7 : day;
  1450. var offset = this.offsetDay;
  1451. var rows = this.tableRows;
  1452. var count = 1;
  1453. var firstDayPosition = void 0;
  1454. var startDate = this.startDate;
  1455. var disabledDate = this.disabledDate;
  1456. var selectedDate = this.selectionMode === 'dates' ? (0, _util2.coerceTruthyValueToArray)(this.value) : [];
  1457. var now = getDateTimestamp(new Date());
  1458. for (var i = 0; i < 6; i++) {
  1459. var row = rows[i];
  1460. if (this.showWeekNumber) {
  1461. if (!row[0]) {
  1462. row[0] = { type: 'week', text: (0, _util.getWeekNumber)((0, _util.nextDate)(startDate, i * 7 + 1)) };
  1463. }
  1464. }
  1465. var _loop = function _loop(j) {
  1466. var cell = row[_this.showWeekNumber ? j + 1 : j];
  1467. if (!cell) {
  1468. cell = { row: i, column: j, type: 'normal', inRange: false, start: false, end: false };
  1469. }
  1470. cell.type = 'normal';
  1471. var index = i * 7 + j;
  1472. var time = (0, _util.nextDate)(startDate, index - offset).getTime();
  1473. cell.inRange = time >= getDateTimestamp(_this.minDate) && time <= getDateTimestamp(_this.maxDate);
  1474. cell.start = _this.minDate && time === getDateTimestamp(_this.minDate);
  1475. cell.end = _this.maxDate && time === getDateTimestamp(_this.maxDate);
  1476. var isToday = time === now;
  1477. if (isToday) {
  1478. cell.type = 'today';
  1479. }
  1480. if (i >= 0 && i <= 1) {
  1481. if (j + i * 7 >= day + offset) {
  1482. cell.text = count++;
  1483. if (count === 2) {
  1484. firstDayPosition = i * 7 + j;
  1485. }
  1486. } else {
  1487. cell.text = dateCountOfLastMonth - (day + offset - j % 7) + 1 + i * 7;
  1488. cell.type = 'prev-month';
  1489. }
  1490. } else {
  1491. if (count <= dateCountOfMonth) {
  1492. cell.text = count++;
  1493. if (count === 2) {
  1494. firstDayPosition = i * 7 + j;
  1495. }
  1496. } else {
  1497. cell.text = count++ - dateCountOfMonth;
  1498. cell.type = 'next-month';
  1499. }
  1500. }
  1501. var cellDate = new Date(time);
  1502. cell.disabled = typeof disabledDate === 'function' && disabledDate(cellDate);
  1503. cell.selected = (0, _util2.arrayFind)(selectedDate, function (date) {
  1504. return date.getTime() === cellDate.getTime();
  1505. });
  1506. _this.$set(row, _this.showWeekNumber ? j + 1 : j, cell);
  1507. };
  1508. for (var j = 0; j < 7; j++) {
  1509. _loop(j);
  1510. }
  1511. if (this.selectionMode === 'week') {
  1512. var start = this.showWeekNumber ? 1 : 0;
  1513. var end = this.showWeekNumber ? 7 : 6;
  1514. var isWeekActive = this.isWeekActive(row[start + 1]);
  1515. row[start].inRange = isWeekActive;
  1516. row[start].start = isWeekActive;
  1517. row[end].inRange = isWeekActive;
  1518. row[end].end = isWeekActive;
  1519. }
  1520. }
  1521. rows.firstDayPosition = firstDayPosition;
  1522. return rows;
  1523. }
  1524. },
  1525. watch: {
  1526. 'rangeState.endDate': function rangeStateEndDate(newVal) {
  1527. this.markRange(this.minDate, newVal);
  1528. },
  1529. minDate: function minDate(newVal, oldVal) {
  1530. if (getDateTimestamp(newVal) !== getDateTimestamp(oldVal)) {
  1531. this.markRange(this.minDate, this.maxDate);
  1532. }
  1533. },
  1534. maxDate: function maxDate(newVal, oldVal) {
  1535. if (getDateTimestamp(newVal) !== getDateTimestamp(oldVal)) {
  1536. this.markRange(this.minDate, this.maxDate);
  1537. }
  1538. }
  1539. },
  1540. data: function data() {
  1541. return {
  1542. tableRows: [[], [], [], [], [], []],
  1543. lastRow: null,
  1544. lastColumn: null
  1545. };
  1546. },
  1547. methods: {
  1548. cellMatchesDate: function cellMatchesDate(cell, date) {
  1549. var value = new Date(date);
  1550. return this.year === value.getFullYear() && this.month === value.getMonth() && Number(cell.text) === value.getDate();
  1551. },
  1552. getCellClasses: function getCellClasses(cell) {
  1553. var _this2 = this;
  1554. var selectionMode = this.selectionMode;
  1555. var defaultValue = this.defaultValue ? Array.isArray(this.defaultValue) ? this.defaultValue : [this.defaultValue] : [];
  1556. var classes = [];
  1557. if ((cell.type === 'normal' || cell.type === 'today') && !cell.disabled) {
  1558. classes.push('available');
  1559. if (cell.type === 'today') {
  1560. classes.push('today');
  1561. }
  1562. } else {
  1563. classes.push(cell.type);
  1564. }
  1565. if (cell.type === 'normal' && defaultValue.some(function (date) {
  1566. return _this2.cellMatchesDate(cell, date);
  1567. })) {
  1568. classes.push('default');
  1569. }
  1570. if (selectionMode === 'day' && (cell.type === 'normal' || cell.type === 'today') && this.cellMatchesDate(cell, this.value)) {
  1571. classes.push('current');
  1572. }
  1573. if (cell.inRange && (cell.type === 'normal' || cell.type === 'today' || this.selectionMode === 'week')) {
  1574. classes.push('in-range');
  1575. if (cell.start) {
  1576. classes.push('start-date');
  1577. }
  1578. if (cell.end) {
  1579. classes.push('end-date');
  1580. }
  1581. }
  1582. if (cell.disabled) {
  1583. classes.push('disabled');
  1584. }
  1585. if (cell.selected) {
  1586. classes.push('selected');
  1587. }
  1588. return classes.join(' ');
  1589. },
  1590. getDateOfCell: function getDateOfCell(row, column) {
  1591. var offsetFromStart = row * 7 + (column - (this.showWeekNumber ? 1 : 0)) - this.offsetDay;
  1592. return (0, _util.nextDate)(this.startDate, offsetFromStart);
  1593. },
  1594. isWeekActive: function isWeekActive(cell) {
  1595. if (this.selectionMode !== 'week') return false;
  1596. var newDate = new Date(this.year, this.month, 1);
  1597. var year = newDate.getFullYear();
  1598. var month = newDate.getMonth();
  1599. if (cell.type === 'prev-month') {
  1600. newDate.setMonth(month === 0 ? 11 : month - 1);
  1601. newDate.setFullYear(month === 0 ? year - 1 : year);
  1602. }
  1603. if (cell.type === 'next-month') {
  1604. newDate.setMonth(month === 11 ? 0 : month + 1);
  1605. newDate.setFullYear(month === 11 ? year + 1 : year);
  1606. }
  1607. newDate.setDate(parseInt(cell.text, 10));
  1608. var valueYear = (0, _util.isDate)(this.value) ? this.value.getFullYear() : null;
  1609. return year === valueYear && (0, _util.getWeekNumber)(newDate) === (0, _util.getWeekNumber)(this.value);
  1610. },
  1611. markRange: function markRange(minDate, maxDate) {
  1612. minDate = getDateTimestamp(minDate);
  1613. maxDate = getDateTimestamp(maxDate) || minDate;
  1614. var _ref = [Math.min(minDate, maxDate), Math.max(minDate, maxDate)];
  1615. minDate = _ref[0];
  1616. maxDate = _ref[1];
  1617. var startDate = this.startDate;
  1618. var rows = this.rows;
  1619. for (var i = 0, k = rows.length; i < k; i++) {
  1620. var row = rows[i];
  1621. for (var j = 0, l = row.length; j < l; j++) {
  1622. if (this.showWeekNumber && j === 0) continue;
  1623. var _cell = row[j];
  1624. var index = i * 7 + j + (this.showWeekNumber ? -1 : 0);
  1625. var time = (0, _util.nextDate)(startDate, index - this.offsetDay).getTime();
  1626. _cell.inRange = minDate && time >= minDate && time <= maxDate;
  1627. _cell.start = minDate && time === minDate;
  1628. _cell.end = maxDate && time === maxDate;
  1629. }
  1630. }
  1631. },
  1632. handleMouseMove: function handleMouseMove(event) {
  1633. if (!this.rangeState.selecting) return;
  1634. var target = event.target;
  1635. if (target.tagName === 'SPAN') {
  1636. target = target.parentNode.parentNode;
  1637. }
  1638. if (target.tagName === 'DIV') {
  1639. target = target.parentNode;
  1640. }
  1641. if (target.tagName !== 'TD') return;
  1642. var row = target.parentNode.rowIndex - 1;
  1643. var column = target.cellIndex;
  1644. // can not select disabled date
  1645. if (this.rows[row][column].disabled) return;
  1646. // only update rangeState when mouse moves to a new cell
  1647. // this avoids frequent Date object creation and improves performance
  1648. if (row !== this.lastRow || column !== this.lastColumn) {
  1649. this.lastRow = row;
  1650. this.lastColumn = column;
  1651. this.$emit('changerange', {
  1652. minDate: this.minDate,
  1653. maxDate: this.maxDate,
  1654. rangeState: {
  1655. selecting: true,
  1656. endDate: this.getDateOfCell(row, column)
  1657. }
  1658. });
  1659. }
  1660. },
  1661. handleClick: function handleClick(event) {
  1662. var target = event.target;
  1663. if (target.tagName === 'SPAN') {
  1664. target = target.parentNode.parentNode;
  1665. }
  1666. if (target.tagName === 'DIV') {
  1667. target = target.parentNode;
  1668. }
  1669. if (target.tagName !== 'TD') return;
  1670. var row = target.parentNode.rowIndex - 1;
  1671. var column = this.selectionMode === 'week' ? 1 : target.cellIndex;
  1672. var cell = this.rows[row][column];
  1673. if (cell.disabled || cell.type === 'week') return;
  1674. var newDate = this.getDateOfCell(row, column);
  1675. if (this.selectionMode === 'range') {
  1676. if (!this.rangeState.selecting) {
  1677. this.$emit('pick', { minDate: newDate, maxDate: null });
  1678. this.rangeState.selecting = true;
  1679. } else {
  1680. if (newDate >= this.minDate) {
  1681. this.$emit('pick', { minDate: this.minDate, maxDate: newDate });
  1682. } else {
  1683. this.$emit('pick', { minDate: newDate, maxDate: this.minDate });
  1684. }
  1685. this.rangeState.selecting = false;
  1686. }
  1687. } else if (this.selectionMode === 'day') {
  1688. this.$emit('pick', newDate);
  1689. } else if (this.selectionMode === 'week') {
  1690. var weekNumber = (0, _util.getWeekNumber)(newDate);
  1691. var value = newDate.getFullYear() + 'w' + weekNumber;
  1692. this.$emit('pick', {
  1693. year: newDate.getFullYear(),
  1694. week: weekNumber,
  1695. value: value,
  1696. date: newDate
  1697. });
  1698. } else if (this.selectionMode === 'dates') {
  1699. var _value = this.value || [];
  1700. var newValue = cell.selected ? removeFromArray(_value, function (date) {
  1701. return date.getTime() === newDate.getTime();
  1702. }) : [].concat(_value, [newDate]);
  1703. this.$emit('pick', newValue);
  1704. }
  1705. }
  1706. }
  1707. };
  1708. /***/ }),
  1709. /***/ 187:
  1710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1711. "use strict";
  1712. var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('table',{staticClass:"el-date-table",class:{ 'is-week-mode': _vm.selectionMode === 'week' },attrs:{"cellspacing":"0","cellpadding":"0"},on:{"click":_vm.handleClick,"mousemove":_vm.handleMouseMove}},[_c('tbody',[_c('tr',[(_vm.showWeekNumber)?_c('th',[_vm._v(_vm._s(_vm.t('el.datepicker.week')))]):_vm._e(),_vm._l((_vm.WEEKS),function(week,key){return _c('th',{key:key},[_vm._v(_vm._s(_vm.t('el.datepicker.weeks.' + week)))])})],2),_vm._l((_vm.rows),function(row,key){return _c('tr',{key:key,staticClass:"el-date-table__row",class:{ current: _vm.isWeekActive(row[1]) }},_vm._l((row),function(cell,key){return _c('td',{key:key,class:_vm.getCellClasses(cell)},[_c('div',[_c('span',[_vm._v("\n "+_vm._s(cell.text)+"\n ")])])])}))})],2)])}
  1713. var staticRenderFns = []
  1714. var esExports = { render: render, staticRenderFns: staticRenderFns }
  1715. /* harmony default export */ __webpack_exports__["a"] = (esExports);
  1716. /***/ }),
  1717. /***/ 188:
  1718. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1719. "use strict";
  1720. var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('transition',{attrs:{"name":"el-zoom-in-top"},on:{"after-enter":_vm.handleEnter,"after-leave":_vm.handleLeave}},[_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.visible),expression:"visible"}],staticClass:"el-picker-panel el-date-picker el-popper",class:[{
  1721. 'has-sidebar': _vm.$slots.sidebar || _vm.shortcuts,
  1722. 'has-time': _vm.showTime
  1723. }, _vm.popperClass]},[_c('div',{staticClass:"el-picker-panel__body-wrapper"},[_vm._t("sidebar"),(_vm.shortcuts)?_c('div',{staticClass:"el-picker-panel__sidebar"},_vm._l((_vm.shortcuts),function(shortcut,key){return _c('button',{key:key,staticClass:"el-picker-panel__shortcut",attrs:{"type":"button"},on:{"click":function($event){_vm.handleShortcutClick(shortcut)}}},[_vm._v(_vm._s(shortcut.text))])})):_vm._e(),_c('div',{staticClass:"el-picker-panel__body"},[(_vm.showTime)?_c('div',{staticClass:"el-date-picker__time-header"},[_c('span',{staticClass:"el-date-picker__editor-wrap"},[_c('el-input',{attrs:{"placeholder":_vm.t('el.datepicker.selectDate'),"value":_vm.visibleDate,"size":"small"},on:{"input":function (val) { return _vm.userInputDate = val; },"change":_vm.handleVisibleDateChange}})],1),_c('span',{directives:[{name:"clickoutside",rawName:"v-clickoutside",value:(_vm.handleTimePickClose),expression:"handleTimePickClose"}],staticClass:"el-date-picker__editor-wrap"},[_c('el-input',{ref:"input",attrs:{"placeholder":_vm.t('el.datepicker.selectTime'),"value":_vm.visibleTime,"size":"small"},on:{"focus":function($event){_vm.timePickerVisible = true},"input":function (val) { return _vm.userInputTime = val; },"change":_vm.handleVisibleTimeChange}}),_c('time-picker',{ref:"timepicker",attrs:{"time-arrow-control":_vm.arrowControl,"visible":_vm.timePickerVisible},on:{"pick":_vm.handleTimePick,"mounted":_vm.proxyTimePickerDataProperties}})],1)]):_vm._e(),_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.currentView !== 'time'),expression:"currentView !== 'time'"}],staticClass:"el-date-picker__header",class:{ 'el-date-picker__header--bordered': _vm.currentView === 'year' || _vm.currentView === 'month' }},[_c('button',{staticClass:"el-picker-panel__icon-btn el-date-picker__prev-btn el-icon-d-arrow-left",attrs:{"type":"button","aria-label":_vm.t("el.datepicker.prevYear")},on:{"click":_vm.prevYear}}),_c('button',{directives:[{name:"show",rawName:"v-show",value:(_vm.currentView === 'date'),expression:"currentView === 'date'"}],staticClass:"el-picker-panel__icon-btn el-date-picker__prev-btn el-icon-arrow-left",attrs:{"type":"button","aria-label":_vm.t("el.datepicker.prevMonth")},on:{"click":_vm.prevMonth}}),_c('span',{staticClass:"el-date-picker__header-label",attrs:{"role":"button"},on:{"click":_vm.showYearPicker}},[_vm._v(_vm._s(_vm.yearLabel))]),_c('span',{directives:[{name:"show",rawName:"v-show",value:(_vm.currentView === 'date'),expression:"currentView === 'date'"}],staticClass:"el-date-picker__header-label",class:{ active: _vm.currentView === 'month' },attrs:{"role":"button"},on:{"click":_vm.showMonthPicker}},[_vm._v(_vm._s(_vm.t(("el.datepicker.month" + (_vm.month + 1)))))]),_c('button',{staticClass:"el-picker-panel__icon-btn el-date-picker__next-btn el-icon-d-arrow-right",attrs:{"type":"button","aria-label":_vm.t("el.datepicker.nextYear")},on:{"click":_vm.nextYear}}),_c('button',{directives:[{name:"show",rawName:"v-show",value:(_vm.currentView === 'date'),expression:"currentView === 'date'"}],staticClass:"el-picker-panel__icon-btn el-date-picker__next-btn el-icon-arrow-right",attrs:{"type":"button","aria-label":_vm.t("el.datepicker.nextMonth")},on:{"click":_vm.nextMonth}})]),_c('div',{staticClass:"el-picker-panel__content"},[_c('date-table',{directives:[{name:"show",rawName:"v-show",value:(_vm.currentView === 'date'),expression:"currentView === 'date'"}],attrs:{"selection-mode":_vm.selectionMode,"first-day-of-week":_vm.firstDayOfWeek,"value":_vm.value,"default-value":_vm.defaultValue ? new Date(_vm.defaultValue) : null,"date":_vm.date,"disabled-date":_vm.disabledDate},on:{"pick":_vm.handleDatePick}}),_c('year-table',{directives:[{name:"show",rawName:"v-show",value:(_vm.currentView === 'year'),expression:"currentView === 'year'"}],attrs:{"value":_vm.value,"default-value":_vm.defaultValue ? new Date(_vm.defaultValue) : null,"date":_vm.date,"disabled-date":_vm.disabledDate},on:{"pick":_vm.handleYearPick}}),_c('month-table',{directives:[{name:"show",rawName:"v-show",value:(_vm.currentView === 'month'),expression:"currentView === 'month'"}],attrs:{"value":_vm.value,"default-value":_vm.defaultValue ? new Date(_vm.defaultValue) : null,"date":_vm.date,"disabled-date":_vm.disabledDate},on:{"pick":_vm.handleMonthPick}})],1)])],2),_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.footerVisible && _vm.currentView === 'date'),expression:"footerVisible && currentView === 'date'"}],staticClass:"el-picker-panel__footer"},[_c('el-button',{directives:[{name:"show",rawName:"v-show",value:(_vm.selectionMode !== 'dates'),expression:"selectionMode !== 'dates'"}],staticClass:"el-picker-panel__link-btn",attrs:{"size":"mini","type":"text"},on:{"click":_vm.changeToNow}},[_vm._v("\n "+_vm._s(_vm.t('el.datepicker.now'))+"\n ")]),_c('el-button',{staticClass:"el-picker-panel__link-btn",attrs:{"plain":"","size":"mini"},on:{"click":_vm.confirm}},[_vm._v("\n "+_vm._s(_vm.t('el.datepicker.confirm'))+"\n ")])],1)])])}
  1724. var staticRenderFns = []
  1725. var esExports = { render: render, staticRenderFns: staticRenderFns }
  1726. /* harmony default export */ __webpack_exports__["a"] = (esExports);
  1727. /***/ }),
  1728. /***/ 189:
  1729. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1730. "use strict";
  1731. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  1732. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_date_range_vue__ = __webpack_require__(190);
  1733. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_date_range_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_date_range_vue__);
  1734. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_52d54177_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_date_range_vue__ = __webpack_require__(191);
  1735. var normalizeComponent = __webpack_require__(0)
  1736. /* script */
  1737. /* template */
  1738. /* template functional */
  1739. var __vue_template_functional__ = false
  1740. /* styles */
  1741. var __vue_styles__ = null
  1742. /* scopeId */
  1743. var __vue_scopeId__ = null
  1744. /* moduleIdentifier (server only) */
  1745. var __vue_module_identifier__ = null
  1746. var Component = normalizeComponent(
  1747. __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_date_range_vue___default.a,
  1748. __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_52d54177_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_date_range_vue__["a" /* default */],
  1749. __vue_template_functional__,
  1750. __vue_styles__,
  1751. __vue_scopeId__,
  1752. __vue_module_identifier__
  1753. )
  1754. /* harmony default export */ __webpack_exports__["default"] = (Component.exports);
  1755. /***/ }),
  1756. /***/ 190:
  1757. /***/ (function(module, exports, __webpack_require__) {
  1758. "use strict";
  1759. exports.__esModule = true;
  1760. var _util = __webpack_require__(11);
  1761. var _clickoutside = __webpack_require__(10);
  1762. var _clickoutside2 = _interopRequireDefault(_clickoutside);
  1763. var _locale = __webpack_require__(5);
  1764. var _locale2 = _interopRequireDefault(_locale);
  1765. var _time = __webpack_require__(31);
  1766. var _time2 = _interopRequireDefault(_time);
  1767. var _dateTable = __webpack_require__(49);
  1768. var _dateTable2 = _interopRequireDefault(_dateTable);
  1769. var _input = __webpack_require__(6);
  1770. var _input2 = _interopRequireDefault(_input);
  1771. var _button = __webpack_require__(15);
  1772. var _button2 = _interopRequireDefault(_button);
  1773. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1774. var advanceDate = function advanceDate(date, amount) {
  1775. return new Date(new Date(date).getTime() + amount);
  1776. }; //
  1777. //
  1778. //
  1779. //
  1780. //
  1781. //
  1782. //
  1783. //
  1784. //
  1785. //
  1786. //
  1787. //
  1788. //
  1789. //
  1790. //
  1791. //
  1792. //
  1793. //
  1794. //
  1795. //
  1796. //
  1797. //
  1798. //
  1799. //
  1800. //
  1801. //
  1802. //
  1803. //
  1804. //
  1805. //
  1806. //
  1807. //
  1808. //
  1809. //
  1810. //
  1811. //
  1812. //
  1813. //
  1814. //
  1815. //
  1816. //
  1817. //
  1818. //
  1819. //
  1820. //
  1821. //
  1822. //
  1823. //
  1824. //
  1825. //
  1826. //
  1827. //
  1828. //
  1829. //
  1830. //
  1831. //
  1832. //
  1833. //
  1834. //
  1835. //
  1836. //
  1837. //
  1838. //
  1839. //
  1840. //
  1841. //
  1842. //
  1843. //
  1844. //
  1845. //
  1846. //
  1847. //
  1848. //
  1849. //
  1850. //
  1851. //
  1852. //
  1853. //
  1854. //
  1855. //
  1856. //
  1857. //
  1858. //
  1859. //
  1860. //
  1861. //
  1862. //
  1863. //
  1864. //
  1865. //
  1866. //
  1867. //
  1868. //
  1869. //
  1870. //
  1871. //
  1872. //
  1873. //
  1874. //
  1875. //
  1876. //
  1877. //
  1878. //
  1879. //
  1880. //
  1881. //
  1882. //
  1883. //
  1884. //
  1885. //
  1886. //
  1887. //
  1888. //
  1889. //
  1890. //
  1891. //
  1892. //
  1893. //
  1894. //
  1895. //
  1896. //
  1897. //
  1898. //
  1899. //
  1900. //
  1901. //
  1902. //
  1903. //
  1904. //
  1905. //
  1906. //
  1907. //
  1908. //
  1909. //
  1910. //
  1911. //
  1912. //
  1913. //
  1914. //
  1915. //
  1916. //
  1917. //
  1918. //
  1919. //
  1920. //
  1921. //
  1922. //
  1923. //
  1924. //
  1925. //
  1926. //
  1927. //
  1928. //
  1929. //
  1930. //
  1931. //
  1932. //
  1933. //
  1934. //
  1935. //
  1936. //
  1937. //
  1938. //
  1939. //
  1940. //
  1941. //
  1942. //
  1943. //
  1944. //
  1945. //
  1946. //
  1947. //
  1948. //
  1949. //
  1950. //
  1951. //
  1952. //
  1953. //
  1954. //
  1955. //
  1956. //
  1957. //
  1958. //
  1959. //
  1960. //
  1961. //
  1962. var calcDefaultValue = function calcDefaultValue(defaultValue) {
  1963. if (Array.isArray(defaultValue)) {
  1964. return [new Date(defaultValue[0]), new Date(defaultValue[1])];
  1965. } else if (defaultValue) {
  1966. return [new Date(defaultValue), advanceDate(defaultValue, 24 * 60 * 60 * 1000)];
  1967. } else {
  1968. return [new Date(), advanceDate(Date.now(), 24 * 60 * 60 * 1000)];
  1969. }
  1970. };
  1971. exports.default = {
  1972. mixins: [_locale2.default],
  1973. directives: { Clickoutside: _clickoutside2.default },
  1974. computed: {
  1975. btnDisabled: function btnDisabled() {
  1976. return !(this.minDate && this.maxDate && !this.selecting && this.isValidValue([this.minDate, this.maxDate]));
  1977. },
  1978. leftLabel: function leftLabel() {
  1979. return this.leftDate.getFullYear() + ' ' + this.t('el.datepicker.year') + ' ' + this.t('el.datepicker.month' + (this.leftDate.getMonth() + 1));
  1980. },
  1981. rightLabel: function rightLabel() {
  1982. return this.rightDate.getFullYear() + ' ' + this.t('el.datepicker.year') + ' ' + this.t('el.datepicker.month' + (this.rightDate.getMonth() + 1));
  1983. },
  1984. leftYear: function leftYear() {
  1985. return this.leftDate.getFullYear();
  1986. },
  1987. leftMonth: function leftMonth() {
  1988. return this.leftDate.getMonth();
  1989. },
  1990. leftMonthDate: function leftMonthDate() {
  1991. return this.leftDate.getDate();
  1992. },
  1993. rightYear: function rightYear() {
  1994. return this.rightDate.getFullYear();
  1995. },
  1996. rightMonth: function rightMonth() {
  1997. return this.rightDate.getMonth();
  1998. },
  1999. rightMonthDate: function rightMonthDate() {
  2000. return this.rightDate.getDate();
  2001. },
  2002. minVisibleDate: function minVisibleDate() {
  2003. return this.minDate ? (0, _util.formatDate)(this.minDate, this.dateFormat) : '';
  2004. },
  2005. maxVisibleDate: function maxVisibleDate() {
  2006. return this.maxDate || this.minDate ? (0, _util.formatDate)(this.maxDate || this.minDate, this.dateFormat) : '';
  2007. },
  2008. minVisibleTime: function minVisibleTime() {
  2009. return this.minDate ? (0, _util.formatDate)(this.minDate, this.timeFormat) : '';
  2010. },
  2011. maxVisibleTime: function maxVisibleTime() {
  2012. return this.maxDate || this.minDate ? (0, _util.formatDate)(this.maxDate || this.minDate, this.timeFormat) : '';
  2013. },
  2014. timeFormat: function timeFormat() {
  2015. if (this.format) {
  2016. return (0, _util.extractTimeFormat)(this.format);
  2017. } else {
  2018. return 'HH:mm:ss';
  2019. }
  2020. },
  2021. dateFormat: function dateFormat() {
  2022. if (this.format) {
  2023. return (0, _util.extractDateFormat)(this.format);
  2024. } else {
  2025. return 'yyyy-MM-dd';
  2026. }
  2027. },
  2028. enableMonthArrow: function enableMonthArrow() {
  2029. var nextMonth = (this.leftMonth + 1) % 12;
  2030. var yearOffset = this.leftMonth + 1 >= 12 ? 1 : 0;
  2031. return this.unlinkPanels && new Date(this.leftYear + yearOffset, nextMonth) < new Date(this.rightYear, this.rightMonth);
  2032. },
  2033. enableYearArrow: function enableYearArrow() {
  2034. return this.unlinkPanels && this.rightYear * 12 + this.rightMonth - (this.leftYear * 12 + this.leftMonth + 1) >= 12;
  2035. }
  2036. },
  2037. data: function data() {
  2038. return {
  2039. popperClass: '',
  2040. value: [],
  2041. defaultValue: null,
  2042. defaultTime: null,
  2043. minDate: '',
  2044. maxDate: '',
  2045. leftDate: new Date(),
  2046. rightDate: (0, _util.nextMonth)(new Date()),
  2047. rangeState: {
  2048. endDate: null,
  2049. selecting: false,
  2050. row: null,
  2051. column: null
  2052. },
  2053. showTime: false,
  2054. shortcuts: '',
  2055. visible: '',
  2056. disabledDate: '',
  2057. firstDayOfWeek: 7,
  2058. minTimePickerVisible: false,
  2059. maxTimePickerVisible: false,
  2060. format: '',
  2061. arrowControl: false,
  2062. unlinkPanels: false
  2063. };
  2064. },
  2065. watch: {
  2066. minDate: function minDate(val) {
  2067. var _this = this;
  2068. this.$nextTick(function () {
  2069. if (_this.$refs.maxTimePicker && _this.maxDate && _this.maxDate < _this.minDate) {
  2070. var format = 'HH:mm:ss';
  2071. _this.$refs.maxTimePicker.selectableRange = [[(0, _util.parseDate)((0, _util.formatDate)(_this.minDate, format), format), (0, _util.parseDate)('23:59:59', format)]];
  2072. }
  2073. });
  2074. if (val && this.$refs.minTimePicker) {
  2075. this.$refs.minTimePicker.date = val;
  2076. this.$refs.minTimePicker.value = val;
  2077. }
  2078. },
  2079. maxDate: function maxDate(val) {
  2080. if (val && this.$refs.maxTimePicker) {
  2081. this.$refs.maxTimePicker.date = val;
  2082. this.$refs.maxTimePicker.value = val;
  2083. }
  2084. },
  2085. minTimePickerVisible: function minTimePickerVisible(val) {
  2086. var _this2 = this;
  2087. if (val) {
  2088. this.$nextTick(function () {
  2089. _this2.$refs.minTimePicker.date = _this2.minDate;
  2090. _this2.$refs.minTimePicker.value = _this2.minDate;
  2091. _this2.$refs.minTimePicker.adjustSpinners();
  2092. });
  2093. }
  2094. },
  2095. maxTimePickerVisible: function maxTimePickerVisible(val) {
  2096. var _this3 = this;
  2097. if (val) {
  2098. this.$nextTick(function () {
  2099. _this3.$refs.maxTimePicker.date = _this3.maxDate;
  2100. _this3.$refs.maxTimePicker.value = _this3.maxDate;
  2101. _this3.$refs.maxTimePicker.adjustSpinners();
  2102. });
  2103. }
  2104. },
  2105. value: function value(newVal) {
  2106. if (!newVal) {
  2107. this.minDate = null;
  2108. this.maxDate = null;
  2109. } else if (Array.isArray(newVal)) {
  2110. this.minDate = (0, _util.isDate)(newVal[0]) ? new Date(newVal[0]) : null;
  2111. this.maxDate = (0, _util.isDate)(newVal[1]) ? new Date(newVal[1]) : null;
  2112. if (this.minDate) {
  2113. this.leftDate = this.minDate;
  2114. if (this.unlinkPanels && this.maxDate) {
  2115. var minDateYear = this.minDate.getFullYear();
  2116. var minDateMonth = this.minDate.getMonth();
  2117. var maxDateYear = this.maxDate.getFullYear();
  2118. var maxDateMonth = this.maxDate.getMonth();
  2119. this.rightDate = minDateYear === maxDateYear && minDateMonth === maxDateMonth ? (0, _util.nextMonth)(this.maxDate) : this.maxDate;
  2120. } else {
  2121. this.rightDate = (0, _util.nextMonth)(this.leftDate);
  2122. }
  2123. } else {
  2124. this.leftDate = calcDefaultValue(this.defaultValue)[0];
  2125. this.rightDate = (0, _util.nextMonth)(this.leftDate);
  2126. }
  2127. }
  2128. },
  2129. defaultValue: function defaultValue(val) {
  2130. if (!Array.isArray(this.value)) {
  2131. var _calcDefaultValue = calcDefaultValue(val),
  2132. left = _calcDefaultValue[0],
  2133. right = _calcDefaultValue[1];
  2134. this.leftDate = left;
  2135. this.rightDate = val && val[1] && this.unlinkPanels ? right : (0, _util.nextMonth)(this.leftDate);
  2136. }
  2137. }
  2138. },
  2139. methods: {
  2140. handleClear: function handleClear() {
  2141. this.minDate = null;
  2142. this.maxDate = null;
  2143. this.leftDate = calcDefaultValue(this.defaultValue)[0];
  2144. this.rightDate = (0, _util.nextMonth)(this.leftDate);
  2145. this.$emit('pick', null);
  2146. },
  2147. handleChangeRange: function handleChangeRange(val) {
  2148. this.minDate = val.minDate;
  2149. this.maxDate = val.maxDate;
  2150. this.rangeState = val.rangeState;
  2151. },
  2152. handleDateInput: function handleDateInput(event, type) {
  2153. var value = event.target.value;
  2154. if (value.length !== this.dateFormat.length) return;
  2155. var parsedValue = (0, _util.parseDate)(value, this.dateFormat);
  2156. if (parsedValue) {
  2157. if (typeof this.disabledDate === 'function' && this.disabledDate(new Date(parsedValue))) {
  2158. return;
  2159. }
  2160. if (type === 'min') {
  2161. this.minDate = new Date(parsedValue);
  2162. this.leftDate = new Date(parsedValue);
  2163. this.rightDate = (0, _util.nextMonth)(this.leftDate);
  2164. } else {
  2165. this.maxDate = new Date(parsedValue);
  2166. this.leftDate = (0, _util.prevMonth)(parsedValue);
  2167. this.rightDate = new Date(parsedValue);
  2168. }
  2169. }
  2170. },
  2171. handleDateChange: function handleDateChange(event, type) {
  2172. var value = event.target.value;
  2173. var parsedValue = (0, _util.parseDate)(value, this.dateFormat);
  2174. if (parsedValue) {
  2175. if (type === 'min') {
  2176. this.minDate = (0, _util.modifyDate)(this.minDate, parsedValue.getFullYear(), parsedValue.getMonth(), parsedValue.getDate());
  2177. if (this.minDate > this.maxDate) {
  2178. this.maxDate = this.minDate;
  2179. }
  2180. } else {
  2181. this.maxDate = (0, _util.modifyDate)(this.maxDate, parsedValue.getFullYear(), parsedValue.getMonth(), parsedValue.getDate());
  2182. if (this.maxDate < this.minDate) {
  2183. this.minDate = this.maxDate;
  2184. }
  2185. }
  2186. }
  2187. },
  2188. handleTimeChange: function handleTimeChange(event, type) {
  2189. var value = event.target.value;
  2190. var parsedValue = (0, _util.parseDate)(value, this.timeFormat);
  2191. if (parsedValue) {
  2192. if (type === 'min') {
  2193. this.minDate = (0, _util.modifyTime)(this.minDate, parsedValue.getHours(), parsedValue.getMinutes(), parsedValue.getSeconds());
  2194. if (this.minDate > this.maxDate) {
  2195. this.maxDate = this.minDate;
  2196. }
  2197. this.$refs.minTimePicker.value = this.minDate;
  2198. this.minTimePickerVisible = false;
  2199. } else {
  2200. this.maxDate = (0, _util.modifyTime)(this.maxDate, parsedValue.getHours(), parsedValue.getMinutes(), parsedValue.getSeconds());
  2201. if (this.maxDate < this.minDate) {
  2202. this.minDate = this.maxDate;
  2203. }
  2204. this.$refs.maxTimePicker.value = this.minDate;
  2205. this.maxTimePickerVisible = false;
  2206. }
  2207. }
  2208. },
  2209. handleRangePick: function handleRangePick(val) {
  2210. var _this4 = this;
  2211. var close = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  2212. var defaultTime = this.defaultTime || [];
  2213. var minDate = (0, _util.modifyWithTimeString)(val.minDate, defaultTime[0]);
  2214. var maxDate = (0, _util.modifyWithTimeString)(val.maxDate, defaultTime[1]);
  2215. if (this.maxDate === maxDate && this.minDate === minDate) {
  2216. return;
  2217. }
  2218. this.onPick && this.onPick(val);
  2219. this.maxDate = maxDate;
  2220. this.minDate = minDate;
  2221. // workaround for https://github.com/ElemeFE/element/issues/7539, should remove this block when we don't have to care about Chromium 55 - 57
  2222. setTimeout(function () {
  2223. _this4.maxDate = maxDate;
  2224. _this4.minDate = minDate;
  2225. }, 10);
  2226. if (!close || this.showTime) return;
  2227. this.handleConfirm();
  2228. },
  2229. handleShortcutClick: function handleShortcutClick(shortcut) {
  2230. if (shortcut.onClick) {
  2231. shortcut.onClick(this);
  2232. }
  2233. },
  2234. handleMinTimePick: function handleMinTimePick(value, visible, first) {
  2235. this.minDate = this.minDate || new Date();
  2236. if (value) {
  2237. this.minDate = (0, _util.modifyTime)(this.minDate, value.getHours(), value.getMinutes(), value.getSeconds());
  2238. }
  2239. if (!first) {
  2240. this.minTimePickerVisible = visible;
  2241. }
  2242. if (!this.maxDate || this.maxDate && this.maxDate.getTime() < this.minDate.getTime()) {
  2243. this.maxDate = new Date(this.minDate);
  2244. }
  2245. },
  2246. handleMinTimeClose: function handleMinTimeClose() {
  2247. this.minTimePickerVisible = false;
  2248. },
  2249. handleMaxTimePick: function handleMaxTimePick(value, visible, first) {
  2250. if (this.maxDate && value) {
  2251. this.maxDate = (0, _util.modifyTime)(this.maxDate, value.getHours(), value.getMinutes(), value.getSeconds());
  2252. }
  2253. if (!first) {
  2254. this.maxTimePickerVisible = visible;
  2255. }
  2256. if (this.maxDate && this.minDate && this.minDate.getTime() > this.maxDate.getTime()) {
  2257. this.minDate = new Date(this.maxDate);
  2258. }
  2259. },
  2260. handleMaxTimeClose: function handleMaxTimeClose() {
  2261. this.maxTimePickerVisible = false;
  2262. },
  2263. // leftPrev*, rightNext* need to take care of `unlinkPanels`
  2264. leftPrevYear: function leftPrevYear() {
  2265. this.leftDate = (0, _util.prevYear)(this.leftDate);
  2266. if (!this.unlinkPanels) {
  2267. this.rightDate = (0, _util.nextMonth)(this.leftDate);
  2268. }
  2269. },
  2270. leftPrevMonth: function leftPrevMonth() {
  2271. this.leftDate = (0, _util.prevMonth)(this.leftDate);
  2272. if (!this.unlinkPanels) {
  2273. this.rightDate = (0, _util.nextMonth)(this.leftDate);
  2274. }
  2275. },
  2276. rightNextYear: function rightNextYear() {
  2277. if (!this.unlinkPanels) {
  2278. this.leftDate = (0, _util.nextYear)(this.leftDate);
  2279. this.rightDate = (0, _util.nextMonth)(this.leftDate);
  2280. } else {
  2281. this.rightDate = (0, _util.nextYear)(this.rightDate);
  2282. }
  2283. },
  2284. rightNextMonth: function rightNextMonth() {
  2285. if (!this.unlinkPanels) {
  2286. this.leftDate = (0, _util.nextMonth)(this.leftDate);
  2287. this.rightDate = (0, _util.nextMonth)(this.leftDate);
  2288. } else {
  2289. this.rightDate = (0, _util.nextMonth)(this.rightDate);
  2290. }
  2291. },
  2292. // leftNext*, rightPrev* are called when `unlinkPanels` is true
  2293. leftNextYear: function leftNextYear() {
  2294. this.leftDate = (0, _util.nextYear)(this.leftDate);
  2295. },
  2296. leftNextMonth: function leftNextMonth() {
  2297. this.leftDate = (0, _util.nextMonth)(this.leftDate);
  2298. },
  2299. rightPrevYear: function rightPrevYear() {
  2300. this.rightDate = (0, _util.prevYear)(this.rightDate);
  2301. },
  2302. rightPrevMonth: function rightPrevMonth() {
  2303. this.rightDate = (0, _util.prevMonth)(this.rightDate);
  2304. },
  2305. handleConfirm: function handleConfirm() {
  2306. var visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2307. if (this.isValidValue([this.minDate, this.maxDate])) {
  2308. this.$emit('pick', [this.minDate, this.maxDate], visible);
  2309. }
  2310. },
  2311. isValidValue: function isValidValue(value) {
  2312. return Array.isArray(value) && value && value[0] && value[1] && (0, _util.isDate)(value[0]) && (0, _util.isDate)(value[1]) && value[0].getTime() <= value[1].getTime() && (typeof this.disabledDate === 'function' ? !this.disabledDate(value[0]) && !this.disabledDate(value[1]) : true);
  2313. },
  2314. resetView: function resetView() {
  2315. // NOTE: this is a hack to reset {min, max}Date on picker open.
  2316. // TODO: correct way of doing so is to refactor {min, max}Date to be dependent on value and internal selection state
  2317. // an alternative would be resetView whenever picker becomes visible, should also investigate date-panel's resetView
  2318. this.minDate = this.value && (0, _util.isDate)(this.value[0]) ? new Date(this.value[0]) : null;
  2319. this.maxDate = this.value && (0, _util.isDate)(this.value[0]) ? new Date(this.value[1]) : null;
  2320. }
  2321. },
  2322. components: { TimePicker: _time2.default, DateTable: _dateTable2.default, ElInput: _input2.default, ElButton: _button2.default }
  2323. };
  2324. /***/ }),
  2325. /***/ 191:
  2326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2327. "use strict";
  2328. var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('transition',{attrs:{"name":"el-zoom-in-top"},on:{"after-leave":function($event){_vm.$emit('dodestroy')}}},[_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.visible),expression:"visible"}],staticClass:"el-picker-panel el-date-range-picker el-popper",class:[{
  2329. 'has-sidebar': _vm.$slots.sidebar || _vm.shortcuts,
  2330. 'has-time': _vm.showTime
  2331. }, _vm.popperClass]},[_c('div',{staticClass:"el-picker-panel__body-wrapper"},[_vm._t("sidebar"),(_vm.shortcuts)?_c('div',{staticClass:"el-picker-panel__sidebar"},_vm._l((_vm.shortcuts),function(shortcut,key){return _c('button',{key:key,staticClass:"el-picker-panel__shortcut",attrs:{"type":"button"},on:{"click":function($event){_vm.handleShortcutClick(shortcut)}}},[_vm._v(_vm._s(shortcut.text))])})):_vm._e(),_c('div',{staticClass:"el-picker-panel__body"},[(_vm.showTime)?_c('div',{staticClass:"el-date-range-picker__time-header"},[_c('span',{staticClass:"el-date-range-picker__editors-wrap"},[_c('span',{staticClass:"el-date-range-picker__time-picker-wrap"},[_c('el-input',{ref:"minInput",staticClass:"el-date-range-picker__editor",attrs:{"size":"small","disabled":_vm.rangeState.selecting,"placeholder":_vm.t('el.datepicker.startDate'),"value":_vm.minVisibleDate},nativeOn:{"input":function($event){_vm.handleDateInput($event, 'min')},"change":function($event){_vm.handleDateChange($event, 'min')}}})],1),_c('span',{directives:[{name:"clickoutside",rawName:"v-clickoutside",value:(_vm.handleMinTimeClose),expression:"handleMinTimeClose"}],staticClass:"el-date-range-picker__time-picker-wrap"},[_c('el-input',{staticClass:"el-date-range-picker__editor",attrs:{"size":"small","disabled":_vm.rangeState.selecting,"placeholder":_vm.t('el.datepicker.startTime'),"value":_vm.minVisibleTime},on:{"focus":function($event){_vm.minTimePickerVisible = true}},nativeOn:{"change":function($event){_vm.handleTimeChange($event, 'min')}}}),_c('time-picker',{ref:"minTimePicker",attrs:{"time-arrow-control":_vm.arrowControl,"visible":_vm.minTimePickerVisible},on:{"pick":_vm.handleMinTimePick,"mounted":function($event){_vm.$refs.minTimePicker.format=_vm.timeFormat}}})],1)]),_c('span',{staticClass:"el-icon-arrow-right"}),_c('span',{staticClass:"el-date-range-picker__editors-wrap is-right"},[_c('span',{staticClass:"el-date-range-picker__time-picker-wrap"},[_c('el-input',{staticClass:"el-date-range-picker__editor",attrs:{"size":"small","disabled":_vm.rangeState.selecting,"placeholder":_vm.t('el.datepicker.endDate'),"value":_vm.maxVisibleDate,"readonly":!_vm.minDate},nativeOn:{"input":function($event){_vm.handleDateInput($event, 'max')},"change":function($event){_vm.handleDateChange($event, 'max')}}})],1),_c('span',{directives:[{name:"clickoutside",rawName:"v-clickoutside",value:(_vm.handleMaxTimeClose),expression:"handleMaxTimeClose"}],staticClass:"el-date-range-picker__time-picker-wrap"},[_c('el-input',{ref:"maxInput",staticClass:"el-date-range-picker__editor",attrs:{"size":"small","disabled":_vm.rangeState.selecting,"placeholder":_vm.t('el.datepicker.endTime'),"value":_vm.maxVisibleTime,"readonly":!_vm.minDate},on:{"focus":function($event){_vm.minDate && (_vm.maxTimePickerVisible = true)}},nativeOn:{"change":function($event){_vm.handleTimeChange($event, 'max')}}}),_c('time-picker',{ref:"maxTimePicker",attrs:{"time-arrow-control":_vm.arrowControl,"visible":_vm.maxTimePickerVisible},on:{"pick":_vm.handleMaxTimePick,"mounted":function($event){_vm.$refs.maxTimePicker.format=_vm.timeFormat}}})],1)])]):_vm._e(),_c('div',{staticClass:"el-picker-panel__content el-date-range-picker__content is-left"},[_c('div',{staticClass:"el-date-range-picker__header"},[_c('button',{staticClass:"el-picker-panel__icon-btn el-icon-d-arrow-left",attrs:{"type":"button"},on:{"click":_vm.leftPrevYear}}),_c('button',{staticClass:"el-picker-panel__icon-btn el-icon-arrow-left",attrs:{"type":"button"},on:{"click":_vm.leftPrevMonth}}),(_vm.unlinkPanels)?_c('button',{staticClass:"el-picker-panel__icon-btn el-icon-d-arrow-right",class:{ 'is-disabled': !_vm.enableYearArrow },attrs:{"type":"button","disabled":!_vm.enableYearArrow},on:{"click":_vm.leftNextYear}}):_vm._e(),(_vm.unlinkPanels)?_c('button',{staticClass:"el-picker-panel__icon-btn el-icon-arrow-right",class:{ 'is-disabled': !_vm.enableMonthArrow },attrs:{"type":"button","disabled":!_vm.enableMonthArrow},on:{"click":_vm.leftNextMonth}}):_vm._e(),_c('div',[_vm._v(_vm._s(_vm.leftLabel))])]),_c('date-table',{attrs:{"selection-mode":"range","date":_vm.leftDate,"default-value":_vm.defaultValue,"min-date":_vm.minDate,"max-date":_vm.maxDate,"range-state":_vm.rangeState,"disabled-date":_vm.disabledDate,"first-day-of-week":_vm.firstDayOfWeek},on:{"changerange":_vm.handleChangeRange,"pick":_vm.handleRangePick}})],1),_c('div',{staticClass:"el-picker-panel__content el-date-range-picker__content is-right"},[_c('div',{staticClass:"el-date-range-picker__header"},[(_vm.unlinkPanels)?_c('button',{staticClass:"el-picker-panel__icon-btn el-icon-d-arrow-left",class:{ 'is-disabled': !_vm.enableYearArrow },attrs:{"type":"button","disabled":!_vm.enableYearArrow},on:{"click":_vm.rightPrevYear}}):_vm._e(),(_vm.unlinkPanels)?_c('button',{staticClass:"el-picker-panel__icon-btn el-icon-arrow-left",class:{ 'is-disabled': !_vm.enableMonthArrow },attrs:{"type":"button","disabled":!_vm.enableMonthArrow},on:{"click":_vm.rightPrevMonth}}):_vm._e(),_c('button',{staticClass:"el-picker-panel__icon-btn el-icon-d-arrow-right",attrs:{"type":"button"},on:{"click":_vm.rightNextYear}}),_c('button',{staticClass:"el-picker-panel__icon-btn el-icon-arrow-right",attrs:{"type":"button"},on:{"click":_vm.rightNextMonth}}),_c('div',[_vm._v(_vm._s(_vm.rightLabel))])]),_c('date-table',{attrs:{"selection-mode":"range","date":_vm.rightDate,"default-value":_vm.defaultValue,"min-date":_vm.minDate,"max-date":_vm.maxDate,"range-state":_vm.rangeState,"disabled-date":_vm.disabledDate,"first-day-of-week":_vm.firstDayOfWeek},on:{"changerange":_vm.handleChangeRange,"pick":_vm.handleRangePick}})],1)])],2),(_vm.showTime)?_c('div',{staticClass:"el-picker-panel__footer"},[_c('el-button',{staticClass:"el-picker-panel__link-btn",attrs:{"size":"mini","type":"text"},on:{"click":_vm.handleClear}},[_vm._v("\n "+_vm._s(_vm.t('el.datepicker.clear'))+"\n ")]),_c('el-button',{staticClass:"el-picker-panel__link-btn",attrs:{"plain":"","size":"mini","disabled":_vm.btnDisabled},on:{"click":function($event){_vm.handleConfirm(false)}}},[_vm._v("\n "+_vm._s(_vm.t('el.datepicker.confirm'))+"\n ")])],1):_vm._e()])])}
  2332. var staticRenderFns = []
  2333. var esExports = { render: render, staticRenderFns: staticRenderFns }
  2334. /* harmony default export */ __webpack_exports__["a"] = (esExports);
  2335. /***/ }),
  2336. /***/ 2:
  2337. /***/ (function(module, exports) {
  2338. module.exports = require("element-ui/lib/utils/util");
  2339. /***/ }),
  2340. /***/ 24:
  2341. /***/ (function(module, exports, __webpack_require__) {
  2342. "use strict";
  2343. exports.__esModule = true;
  2344. var _dom = __webpack_require__(3);
  2345. exports.default = {
  2346. bind: function bind(el, binding, vnode) {
  2347. var interval = null;
  2348. var startTime = void 0;
  2349. var handler = function handler() {
  2350. return vnode.context[binding.expression].apply();
  2351. };
  2352. var clear = function clear() {
  2353. if (new Date() - startTime < 100) {
  2354. handler();
  2355. }
  2356. clearInterval(interval);
  2357. interval = null;
  2358. };
  2359. (0, _dom.on)(el, 'mousedown', function (e) {
  2360. if (e.button !== 0) return;
  2361. startTime = new Date();
  2362. (0, _dom.once)(document, 'mouseup', clear);
  2363. clearInterval(interval);
  2364. interval = setInterval(handler, 100);
  2365. });
  2366. }
  2367. };
  2368. /***/ }),
  2369. /***/ 27:
  2370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2371. "use strict";
  2372. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  2373. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_picker_vue__ = __webpack_require__(28);
  2374. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_picker_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_picker_vue__);
  2375. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_72d0c3bc_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_picker_vue__ = __webpack_require__(30);
  2376. var normalizeComponent = __webpack_require__(0)
  2377. /* script */
  2378. /* template */
  2379. /* template functional */
  2380. var __vue_template_functional__ = false
  2381. /* styles */
  2382. var __vue_styles__ = null
  2383. /* scopeId */
  2384. var __vue_scopeId__ = null
  2385. /* moduleIdentifier (server only) */
  2386. var __vue_module_identifier__ = null
  2387. var Component = normalizeComponent(
  2388. __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_picker_vue___default.a,
  2389. __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_72d0c3bc_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_picker_vue__["a" /* default */],
  2390. __vue_template_functional__,
  2391. __vue_styles__,
  2392. __vue_scopeId__,
  2393. __vue_module_identifier__
  2394. )
  2395. /* harmony default export */ __webpack_exports__["default"] = (Component.exports);
  2396. /***/ }),
  2397. /***/ 28:
  2398. /***/ (function(module, exports, __webpack_require__) {
  2399. "use strict";
  2400. exports.__esModule = true;
  2401. var _vue = __webpack_require__(4);
  2402. var _vue2 = _interopRequireDefault(_vue);
  2403. var _clickoutside = __webpack_require__(10);
  2404. var _clickoutside2 = _interopRequireDefault(_clickoutside);
  2405. var _util = __webpack_require__(11);
  2406. var _vuePopper = __webpack_require__(7);
  2407. var _vuePopper2 = _interopRequireDefault(_vuePopper);
  2408. var _emitter = __webpack_require__(1);
  2409. var _emitter2 = _interopRequireDefault(_emitter);
  2410. var _input = __webpack_require__(6);
  2411. var _input2 = _interopRequireDefault(_input);
  2412. var _merge = __webpack_require__(9);
  2413. var _merge2 = _interopRequireDefault(_merge);
  2414. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2415. var NewPopper = {
  2416. props: {
  2417. appendToBody: _vuePopper2.default.props.appendToBody,
  2418. offset: _vuePopper2.default.props.offset,
  2419. boundariesPadding: _vuePopper2.default.props.boundariesPadding,
  2420. arrowOffset: _vuePopper2.default.props.arrowOffset
  2421. },
  2422. methods: _vuePopper2.default.methods,
  2423. data: function data() {
  2424. return (0, _merge2.default)({ visibleArrow: true }, _vuePopper2.default.data);
  2425. },
  2426. beforeDestroy: _vuePopper2.default.beforeDestroy
  2427. }; //
  2428. //
  2429. //
  2430. //
  2431. //
  2432. //
  2433. //
  2434. //
  2435. //
  2436. //
  2437. //
  2438. //
  2439. //
  2440. //
  2441. //
  2442. //
  2443. //
  2444. //
  2445. //
  2446. //
  2447. //
  2448. //
  2449. //
  2450. //
  2451. //
  2452. //
  2453. //
  2454. //
  2455. //
  2456. //
  2457. //
  2458. //
  2459. //
  2460. //
  2461. //
  2462. //
  2463. //
  2464. //
  2465. //
  2466. //
  2467. //
  2468. //
  2469. //
  2470. //
  2471. //
  2472. //
  2473. //
  2474. //
  2475. //
  2476. //
  2477. //
  2478. //
  2479. //
  2480. //
  2481. //
  2482. //
  2483. //
  2484. //
  2485. //
  2486. //
  2487. //
  2488. //
  2489. //
  2490. //
  2491. //
  2492. //
  2493. //
  2494. //
  2495. //
  2496. //
  2497. //
  2498. //
  2499. //
  2500. //
  2501. //
  2502. //
  2503. //
  2504. //
  2505. //
  2506. //
  2507. //
  2508. //
  2509. //
  2510. //
  2511. //
  2512. var DEFAULT_FORMATS = {
  2513. date: 'yyyy-MM-dd',
  2514. month: 'yyyy-MM',
  2515. datetime: 'yyyy-MM-dd HH:mm:ss',
  2516. time: 'HH:mm:ss',
  2517. week: 'yyyywWW',
  2518. timerange: 'HH:mm:ss',
  2519. daterange: 'yyyy-MM-dd',
  2520. datetimerange: 'yyyy-MM-dd HH:mm:ss',
  2521. year: 'yyyy'
  2522. };
  2523. var HAVE_TRIGGER_TYPES = ['date', 'datetime', 'time', 'time-select', 'week', 'month', 'year', 'daterange', 'timerange', 'datetimerange', 'dates'];
  2524. var DATE_FORMATTER = function DATE_FORMATTER(value, format) {
  2525. if (format === 'timestamp') return value.getTime();
  2526. return (0, _util.formatDate)(value, format);
  2527. };
  2528. var DATE_PARSER = function DATE_PARSER(text, format) {
  2529. if (format === 'timestamp') return new Date(Number(text));
  2530. return (0, _util.parseDate)(text, format);
  2531. };
  2532. var RANGE_FORMATTER = function RANGE_FORMATTER(value, format) {
  2533. if (Array.isArray(value) && value.length === 2) {
  2534. var start = value[0];
  2535. var end = value[1];
  2536. if (start && end) {
  2537. return [DATE_FORMATTER(start, format), DATE_FORMATTER(end, format)];
  2538. }
  2539. }
  2540. return '';
  2541. };
  2542. var RANGE_PARSER = function RANGE_PARSER(array, format, separator) {
  2543. if (!Array.isArray(array)) {
  2544. array = array.split(separator);
  2545. }
  2546. if (array.length === 2) {
  2547. var range1 = array[0];
  2548. var range2 = array[1];
  2549. return [DATE_PARSER(range1, format), DATE_PARSER(range2, format)];
  2550. }
  2551. return [];
  2552. };
  2553. var TYPE_VALUE_RESOLVER_MAP = {
  2554. default: {
  2555. formatter: function formatter(value) {
  2556. if (!value) return '';
  2557. return '' + value;
  2558. },
  2559. parser: function parser(text) {
  2560. if (text === undefined || text === '') return null;
  2561. return text;
  2562. }
  2563. },
  2564. week: {
  2565. formatter: function formatter(value, format) {
  2566. var week = (0, _util.getWeekNumber)(value);
  2567. var month = value.getMonth();
  2568. var trueDate = new Date(value);
  2569. if (week === 1 && month === 11) {
  2570. trueDate.setHours(0, 0, 0, 0);
  2571. trueDate.setDate(trueDate.getDate() + 3 - (trueDate.getDay() + 6) % 7);
  2572. }
  2573. var date = (0, _util.formatDate)(trueDate, format);
  2574. date = /WW/.test(date) ? date.replace(/WW/, week < 10 ? '0' + week : week) : date.replace(/W/, week);
  2575. return date;
  2576. },
  2577. parser: function parser(text) {
  2578. var array = (text || '').split('w');
  2579. if (array.length === 2) {
  2580. var year = Number(array[0]);
  2581. var month = Number(array[1]);
  2582. if (!isNaN(year) && !isNaN(month) && month < 54) {
  2583. return text;
  2584. }
  2585. }
  2586. return null;
  2587. }
  2588. },
  2589. date: {
  2590. formatter: DATE_FORMATTER,
  2591. parser: DATE_PARSER
  2592. },
  2593. datetime: {
  2594. formatter: DATE_FORMATTER,
  2595. parser: DATE_PARSER
  2596. },
  2597. daterange: {
  2598. formatter: RANGE_FORMATTER,
  2599. parser: RANGE_PARSER
  2600. },
  2601. datetimerange: {
  2602. formatter: RANGE_FORMATTER,
  2603. parser: RANGE_PARSER
  2604. },
  2605. timerange: {
  2606. formatter: RANGE_FORMATTER,
  2607. parser: RANGE_PARSER
  2608. },
  2609. time: {
  2610. formatter: DATE_FORMATTER,
  2611. parser: DATE_PARSER
  2612. },
  2613. month: {
  2614. formatter: DATE_FORMATTER,
  2615. parser: DATE_PARSER
  2616. },
  2617. year: {
  2618. formatter: DATE_FORMATTER,
  2619. parser: DATE_PARSER
  2620. },
  2621. number: {
  2622. formatter: function formatter(value) {
  2623. if (!value) return '';
  2624. return '' + value;
  2625. },
  2626. parser: function parser(text) {
  2627. var result = Number(text);
  2628. if (!isNaN(text)) {
  2629. return result;
  2630. } else {
  2631. return null;
  2632. }
  2633. }
  2634. },
  2635. dates: {
  2636. formatter: function formatter(value, format) {
  2637. return value.map(function (date) {
  2638. return DATE_FORMATTER(date, format);
  2639. });
  2640. },
  2641. parser: function parser(value, format) {
  2642. return (typeof value === 'string' ? value.split(', ') : value).map(function (date) {
  2643. return date instanceof Date ? date : DATE_PARSER(date, format);
  2644. });
  2645. }
  2646. }
  2647. };
  2648. var PLACEMENT_MAP = {
  2649. left: 'bottom-start',
  2650. center: 'bottom',
  2651. right: 'bottom-end'
  2652. };
  2653. var parseAsFormatAndType = function parseAsFormatAndType(value, customFormat, type) {
  2654. var rangeSeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '-';
  2655. if (!value) return null;
  2656. var parser = (TYPE_VALUE_RESOLVER_MAP[type] || TYPE_VALUE_RESOLVER_MAP['default']).parser;
  2657. var format = customFormat || DEFAULT_FORMATS[type];
  2658. return parser(value, format, rangeSeparator);
  2659. };
  2660. var formatAsFormatAndType = function formatAsFormatAndType(value, customFormat, type) {
  2661. if (!value) return null;
  2662. var formatter = (TYPE_VALUE_RESOLVER_MAP[type] || TYPE_VALUE_RESOLVER_MAP['default']).formatter;
  2663. var format = customFormat || DEFAULT_FORMATS[type];
  2664. return formatter(value, format);
  2665. };
  2666. /*
  2667. * Considers:
  2668. * 1. Date object
  2669. * 2. date string
  2670. * 3. array of 1 or 2
  2671. */
  2672. var valueEquals = function valueEquals(a, b) {
  2673. // considers Date object and string
  2674. var dateEquals = function dateEquals(a, b) {
  2675. var aIsDate = a instanceof Date;
  2676. var bIsDate = b instanceof Date;
  2677. if (aIsDate && bIsDate) {
  2678. return a.getTime() === b.getTime();
  2679. }
  2680. if (!aIsDate && !bIsDate) {
  2681. return a === b;
  2682. }
  2683. return false;
  2684. };
  2685. var aIsArray = a instanceof Array;
  2686. var bIsArray = b instanceof Array;
  2687. if (aIsArray && bIsArray) {
  2688. if (a.length !== b.length) {
  2689. return false;
  2690. }
  2691. return a.every(function (item, index) {
  2692. return dateEquals(item, b[index]);
  2693. });
  2694. }
  2695. if (!aIsArray && !bIsArray) {
  2696. return dateEquals(a, b);
  2697. }
  2698. return false;
  2699. };
  2700. var isString = function isString(val) {
  2701. return typeof val === 'string' || val instanceof String;
  2702. };
  2703. var validator = function validator(val) {
  2704. // either: String, Array of String, null / undefined
  2705. return val === null || val === undefined || isString(val) || Array.isArray(val) && val.length === 2 && val.every(isString);
  2706. };
  2707. exports.default = {
  2708. mixins: [_emitter2.default, NewPopper],
  2709. inject: {
  2710. elForm: {
  2711. default: ''
  2712. },
  2713. elFormItem: {
  2714. default: ''
  2715. }
  2716. },
  2717. props: {
  2718. size: String,
  2719. format: String,
  2720. valueFormat: String,
  2721. readonly: Boolean,
  2722. placeholder: String,
  2723. startPlaceholder: String,
  2724. endPlaceholder: String,
  2725. prefixIcon: String,
  2726. clearIcon: {
  2727. type: String,
  2728. default: 'el-icon-circle-close'
  2729. },
  2730. name: {
  2731. default: '',
  2732. validator: validator
  2733. },
  2734. disabled: Boolean,
  2735. clearable: {
  2736. type: Boolean,
  2737. default: true
  2738. },
  2739. id: {
  2740. default: '',
  2741. validator: validator
  2742. },
  2743. popperClass: String,
  2744. editable: {
  2745. type: Boolean,
  2746. default: true
  2747. },
  2748. align: {
  2749. type: String,
  2750. default: 'left'
  2751. },
  2752. value: {},
  2753. defaultValue: {},
  2754. defaultTime: {},
  2755. rangeSeparator: {
  2756. default: '-'
  2757. },
  2758. pickerOptions: {},
  2759. unlinkPanels: Boolean
  2760. },
  2761. components: { ElInput: _input2.default },
  2762. directives: { Clickoutside: _clickoutside2.default },
  2763. data: function data() {
  2764. return {
  2765. pickerVisible: false,
  2766. showClose: false,
  2767. userInput: null,
  2768. valueOnOpen: null, // value when picker opens, used to determine whether to emit change
  2769. unwatchPickerOptions: null
  2770. };
  2771. },
  2772. watch: {
  2773. pickerVisible: function pickerVisible(val) {
  2774. if (this.readonly || this.pickerDisabled) return;
  2775. if (val) {
  2776. this.showPicker();
  2777. this.valueOnOpen = Array.isArray(this.value) ? [].concat(this.value) : this.value;
  2778. } else {
  2779. this.hidePicker();
  2780. this.emitChange(this.value);
  2781. this.userInput = null;
  2782. this.dispatch('ElFormItem', 'el.form.blur');
  2783. this.$emit('blur', this);
  2784. this.blur();
  2785. }
  2786. },
  2787. parsedValue: {
  2788. immediate: true,
  2789. handler: function handler(val) {
  2790. if (this.picker) {
  2791. this.picker.value = val;
  2792. }
  2793. }
  2794. },
  2795. defaultValue: function defaultValue(val) {
  2796. // NOTE: should eventually move to jsx style picker + panel ?
  2797. if (this.picker) {
  2798. this.picker.defaultValue = val;
  2799. }
  2800. },
  2801. value: function value(val, oldVal) {
  2802. if (!valueEquals(val, oldVal) && !this.pickerVisible) {
  2803. this.dispatch('ElFormItem', 'el.form.change', val);
  2804. }
  2805. }
  2806. },
  2807. computed: {
  2808. ranged: function ranged() {
  2809. return this.type.indexOf('range') > -1;
  2810. },
  2811. reference: function reference() {
  2812. var reference = this.$refs.reference;
  2813. return reference.$el || reference;
  2814. },
  2815. refInput: function refInput() {
  2816. if (this.reference) {
  2817. return [].slice.call(this.reference.querySelectorAll('input'));
  2818. }
  2819. return [];
  2820. },
  2821. valueIsEmpty: function valueIsEmpty() {
  2822. var val = this.value;
  2823. if (Array.isArray(val)) {
  2824. for (var i = 0, len = val.length; i < len; i++) {
  2825. if (val[i]) {
  2826. return false;
  2827. }
  2828. }
  2829. } else {
  2830. if (val) {
  2831. return false;
  2832. }
  2833. }
  2834. return true;
  2835. },
  2836. triggerClass: function triggerClass() {
  2837. return this.prefixIcon || (this.type.indexOf('time') !== -1 ? 'el-icon-time' : 'el-icon-date');
  2838. },
  2839. selectionMode: function selectionMode() {
  2840. if (this.type === 'week') {
  2841. return 'week';
  2842. } else if (this.type === 'month') {
  2843. return 'month';
  2844. } else if (this.type === 'year') {
  2845. return 'year';
  2846. } else if (this.type === 'dates') {
  2847. return 'dates';
  2848. }
  2849. return 'day';
  2850. },
  2851. haveTrigger: function haveTrigger() {
  2852. if (typeof this.showTrigger !== 'undefined') {
  2853. return this.showTrigger;
  2854. }
  2855. return HAVE_TRIGGER_TYPES.indexOf(this.type) !== -1;
  2856. },
  2857. displayValue: function displayValue() {
  2858. var formattedValue = formatAsFormatAndType(this.parsedValue, this.format, this.type, this.rangeSeparator);
  2859. if (Array.isArray(this.userInput)) {
  2860. return [this.userInput[0] || formattedValue && formattedValue[0] || '', this.userInput[1] || formattedValue && formattedValue[1] || ''];
  2861. } else if (this.userInput !== null) {
  2862. return this.userInput;
  2863. } else if (formattedValue) {
  2864. return this.type === 'dates' ? formattedValue.join(', ') : formattedValue;
  2865. } else {
  2866. return '';
  2867. }
  2868. },
  2869. parsedValue: function parsedValue() {
  2870. if (!this.value) return this.value; // component value is not set
  2871. if (this.type === 'time-select') return this.value; // time-select does not require parsing, this might change in next major version
  2872. var valueIsDateObject = (0, _util.isDateObject)(this.value) || Array.isArray(this.value) && this.value.every(_util.isDateObject);
  2873. if (valueIsDateObject) {
  2874. return this.value;
  2875. }
  2876. if (this.valueFormat) {
  2877. return parseAsFormatAndType(this.value, this.valueFormat, this.type, this.rangeSeparator) || this.value;
  2878. }
  2879. // NOTE: deal with common but incorrect usage, should remove in next major version
  2880. // user might provide string / timestamp without value-format, coerce them into date (or array of date)
  2881. return Array.isArray(this.value) ? this.value.map(function (val) {
  2882. return new Date(val);
  2883. }) : new Date(this.value);
  2884. },
  2885. _elFormItemSize: function _elFormItemSize() {
  2886. return (this.elFormItem || {}).elFormItemSize;
  2887. },
  2888. pickerSize: function pickerSize() {
  2889. return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
  2890. },
  2891. pickerDisabled: function pickerDisabled() {
  2892. return this.disabled || (this.elForm || {}).disabled;
  2893. },
  2894. firstInputId: function firstInputId() {
  2895. var obj = {};
  2896. var id = void 0;
  2897. if (this.ranged) {
  2898. id = this.id && this.id[0];
  2899. } else {
  2900. id = this.id;
  2901. }
  2902. if (id) obj.id = id;
  2903. return obj;
  2904. },
  2905. secondInputId: function secondInputId() {
  2906. var obj = {};
  2907. var id = void 0;
  2908. if (this.ranged) {
  2909. id = this.id && this.id[1];
  2910. }
  2911. if (id) obj.id = id;
  2912. return obj;
  2913. }
  2914. },
  2915. created: function created() {
  2916. // vue-popper
  2917. this.popperOptions = {
  2918. boundariesPadding: 0,
  2919. gpuAcceleration: false
  2920. };
  2921. this.placement = PLACEMENT_MAP[this.align] || PLACEMENT_MAP.left;
  2922. this.$on('fieldReset', this.handleFieldReset);
  2923. },
  2924. methods: {
  2925. focus: function focus() {
  2926. if (!this.ranged) {
  2927. this.$refs.reference.focus();
  2928. } else {
  2929. this.handleFocus();
  2930. }
  2931. },
  2932. blur: function blur() {
  2933. this.refInput.forEach(function (input) {
  2934. return input.blur();
  2935. });
  2936. },
  2937. // {parse, formatTo} Value deals maps component value with internal Date
  2938. parseValue: function parseValue(value) {
  2939. var isParsed = (0, _util.isDateObject)(value) || Array.isArray(value) && value.every(_util.isDateObject);
  2940. if (this.valueFormat && !isParsed) {
  2941. return parseAsFormatAndType(value, this.valueFormat, this.type, this.rangeSeparator) || value;
  2942. } else {
  2943. return value;
  2944. }
  2945. },
  2946. formatToValue: function formatToValue(date) {
  2947. var isFormattable = (0, _util.isDateObject)(date) || Array.isArray(date) && date.every(_util.isDateObject);
  2948. if (this.valueFormat && isFormattable) {
  2949. return formatAsFormatAndType(date, this.valueFormat, this.type, this.rangeSeparator);
  2950. } else {
  2951. return date;
  2952. }
  2953. },
  2954. // {parse, formatTo} String deals with user input
  2955. parseString: function parseString(value) {
  2956. var type = Array.isArray(value) ? this.type : this.type.replace('range', '');
  2957. return parseAsFormatAndType(value, this.format, type);
  2958. },
  2959. formatToString: function formatToString(value) {
  2960. var type = Array.isArray(value) ? this.type : this.type.replace('range', '');
  2961. return formatAsFormatAndType(value, this.format, type);
  2962. },
  2963. handleMouseEnter: function handleMouseEnter() {
  2964. if (this.readonly || this.pickerDisabled) return;
  2965. if (!this.valueIsEmpty && this.clearable) {
  2966. this.showClose = true;
  2967. }
  2968. },
  2969. handleChange: function handleChange() {
  2970. if (this.userInput) {
  2971. var value = this.parseString(this.displayValue);
  2972. if (value) {
  2973. this.picker.value = value;
  2974. if (this.isValidValue(value)) {
  2975. this.emitInput(value);
  2976. this.userInput = null;
  2977. }
  2978. }
  2979. }
  2980. if (this.userInput === '') {
  2981. this.emitInput(null);
  2982. this.emitChange(null);
  2983. this.userInput = null;
  2984. }
  2985. },
  2986. handleStartInput: function handleStartInput(event) {
  2987. if (this.userInput) {
  2988. this.userInput = [event.target.value, this.userInput[1]];
  2989. } else {
  2990. this.userInput = [event.target.value, null];
  2991. }
  2992. },
  2993. handleEndInput: function handleEndInput(event) {
  2994. if (this.userInput) {
  2995. this.userInput = [this.userInput[0], event.target.value];
  2996. } else {
  2997. this.userInput = [null, event.target.value];
  2998. }
  2999. },
  3000. handleStartChange: function handleStartChange(event) {
  3001. var value = this.parseString(this.userInput && this.userInput[0]);
  3002. if (value) {
  3003. this.userInput = [this.formatToString(value), this.displayValue[1]];
  3004. var newValue = [value, this.picker.value && this.picker.value[1]];
  3005. this.picker.value = newValue;
  3006. if (this.isValidValue(newValue)) {
  3007. this.emitInput(newValue);
  3008. this.userInput = null;
  3009. }
  3010. }
  3011. },
  3012. handleEndChange: function handleEndChange(event) {
  3013. var value = this.parseString(this.userInput && this.userInput[1]);
  3014. if (value) {
  3015. this.userInput = [this.displayValue[0], this.formatToString(value)];
  3016. var newValue = [this.picker.value && this.picker.value[0], value];
  3017. this.picker.value = newValue;
  3018. if (this.isValidValue(newValue)) {
  3019. this.emitInput(newValue);
  3020. this.userInput = null;
  3021. }
  3022. }
  3023. },
  3024. handleClickIcon: function handleClickIcon(event) {
  3025. if (this.readonly || this.pickerDisabled) return;
  3026. if (this.showClose) {
  3027. this.valueOnOpen = this.value;
  3028. event.stopPropagation();
  3029. this.emitInput(null);
  3030. this.emitChange(null);
  3031. this.showClose = false;
  3032. if (this.picker && typeof this.picker.handleClear === 'function') {
  3033. this.picker.handleClear();
  3034. }
  3035. } else {
  3036. this.pickerVisible = !this.pickerVisible;
  3037. }
  3038. },
  3039. handleClose: function handleClose() {
  3040. if (!this.pickerVisible) return;
  3041. this.pickerVisible = false;
  3042. if (this.type === 'dates') {
  3043. // restore to former value
  3044. var oldValue = parseAsFormatAndType(this.valueOnOpen, this.valueFormat, this.type, this.rangeSeparator) || this.valueOnOpen;
  3045. this.emitInput(oldValue);
  3046. }
  3047. },
  3048. handleFieldReset: function handleFieldReset(initialValue) {
  3049. this.userInput = initialValue === '' ? null : initialValue;
  3050. },
  3051. handleFocus: function handleFocus() {
  3052. var type = this.type;
  3053. if (HAVE_TRIGGER_TYPES.indexOf(type) !== -1 && !this.pickerVisible) {
  3054. this.pickerVisible = true;
  3055. }
  3056. this.$emit('focus', this);
  3057. },
  3058. handleKeydown: function handleKeydown(event) {
  3059. var _this = this;
  3060. var keyCode = event.keyCode;
  3061. // ESC
  3062. if (keyCode === 27) {
  3063. this.pickerVisible = false;
  3064. event.stopPropagation();
  3065. return;
  3066. }
  3067. // Tab
  3068. if (keyCode === 9) {
  3069. if (!this.ranged) {
  3070. this.handleChange();
  3071. this.pickerVisible = this.picker.visible = false;
  3072. this.blur();
  3073. event.stopPropagation();
  3074. } else {
  3075. // user may change focus between two input
  3076. setTimeout(function () {
  3077. if (_this.refInput.indexOf(document.activeElement) === -1) {
  3078. _this.pickerVisible = false;
  3079. _this.blur();
  3080. event.stopPropagation();
  3081. }
  3082. }, 0);
  3083. }
  3084. return;
  3085. }
  3086. // Enter
  3087. if (keyCode === 13) {
  3088. if (this.userInput === '' || this.isValidValue(this.parseString(this.displayValue))) {
  3089. this.handleChange();
  3090. this.pickerVisible = this.picker.visible = false;
  3091. this.blur();
  3092. }
  3093. event.stopPropagation();
  3094. return;
  3095. }
  3096. // if user is typing, do not let picker handle key input
  3097. if (this.userInput) {
  3098. event.stopPropagation();
  3099. return;
  3100. }
  3101. // delegate other keys to panel
  3102. if (this.picker && this.picker.handleKeydown) {
  3103. this.picker.handleKeydown(event);
  3104. }
  3105. },
  3106. handleRangeClick: function handleRangeClick() {
  3107. var type = this.type;
  3108. if (HAVE_TRIGGER_TYPES.indexOf(type) !== -1 && !this.pickerVisible) {
  3109. this.pickerVisible = true;
  3110. }
  3111. this.$emit('focus', this);
  3112. },
  3113. hidePicker: function hidePicker() {
  3114. if (this.picker) {
  3115. this.picker.resetView && this.picker.resetView();
  3116. this.pickerVisible = this.picker.visible = false;
  3117. this.destroyPopper();
  3118. }
  3119. },
  3120. showPicker: function showPicker() {
  3121. var _this2 = this;
  3122. if (this.$isServer) return;
  3123. if (!this.picker) {
  3124. this.mountPicker();
  3125. }
  3126. this.pickerVisible = this.picker.visible = true;
  3127. this.updatePopper();
  3128. this.picker.value = this.parsedValue;
  3129. this.picker.resetView && this.picker.resetView();
  3130. this.$nextTick(function () {
  3131. _this2.picker.adjustSpinners && _this2.picker.adjustSpinners();
  3132. });
  3133. },
  3134. mountPicker: function mountPicker() {
  3135. var _this3 = this;
  3136. this.picker = new _vue2.default(this.panel).$mount();
  3137. this.picker.defaultValue = this.defaultValue;
  3138. this.picker.defaultTime = this.defaultTime;
  3139. this.picker.popperClass = this.popperClass;
  3140. this.popperElm = this.picker.$el;
  3141. this.picker.width = this.reference.getBoundingClientRect().width;
  3142. this.picker.showTime = this.type === 'datetime' || this.type === 'datetimerange';
  3143. this.picker.selectionMode = this.selectionMode;
  3144. this.picker.unlinkPanels = this.unlinkPanels;
  3145. this.picker.arrowControl = this.arrowControl || this.timeArrowControl || false;
  3146. this.$watch('format', function (format) {
  3147. _this3.picker.format = format;
  3148. });
  3149. var updateOptions = function updateOptions() {
  3150. var options = _this3.pickerOptions;
  3151. if (options && options.selectableRange) {
  3152. (function () {
  3153. var ranges = options.selectableRange;
  3154. var parser = TYPE_VALUE_RESOLVER_MAP.datetimerange.parser;
  3155. var format = DEFAULT_FORMATS.timerange;
  3156. ranges = Array.isArray(ranges) ? ranges : [ranges];
  3157. _this3.picker.selectableRange = ranges.map(function (range) {
  3158. return parser(range, format, _this3.rangeSeparator);
  3159. });
  3160. })();
  3161. }
  3162. for (var option in options) {
  3163. if (options.hasOwnProperty(option) &&
  3164. // 忽略 time-picker 的该配置项
  3165. option !== 'selectableRange') {
  3166. _this3.picker[option] = options[option];
  3167. }
  3168. }
  3169. // main format must prevail over undocumented pickerOptions.format
  3170. if (_this3.format) {
  3171. _this3.picker.format = _this3.format;
  3172. }
  3173. };
  3174. updateOptions();
  3175. this.unwatchPickerOptions = this.$watch('pickerOptions', function () {
  3176. return updateOptions();
  3177. }, { deep: true });
  3178. this.$el.appendChild(this.picker.$el);
  3179. this.picker.resetView && this.picker.resetView();
  3180. this.picker.$on('dodestroy', this.doDestroy);
  3181. this.picker.$on('pick', function () {
  3182. var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  3183. var visible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  3184. _this3.userInput = null;
  3185. _this3.pickerVisible = _this3.picker.visible = visible;
  3186. _this3.emitInput(date);
  3187. _this3.picker.resetView && _this3.picker.resetView();
  3188. });
  3189. this.picker.$on('select-range', function (start, end, pos) {
  3190. if (_this3.refInput.length === 0) return;
  3191. if (!pos || pos === 'min') {
  3192. _this3.refInput[0].setSelectionRange(start, end);
  3193. _this3.refInput[0].focus();
  3194. } else if (pos === 'max') {
  3195. _this3.refInput[1].setSelectionRange(start, end);
  3196. _this3.refInput[1].focus();
  3197. }
  3198. });
  3199. },
  3200. unmountPicker: function unmountPicker() {
  3201. if (this.picker) {
  3202. this.picker.$destroy();
  3203. this.picker.$off();
  3204. if (typeof this.unwatchPickerOptions === 'function') {
  3205. this.unwatchPickerOptions();
  3206. }
  3207. this.picker.$el.parentNode.removeChild(this.picker.$el);
  3208. }
  3209. },
  3210. emitChange: function emitChange(val) {
  3211. // determine user real change only
  3212. if (!valueEquals(val, this.valueOnOpen)) {
  3213. this.$emit('change', val);
  3214. this.dispatch('ElFormItem', 'el.form.change', val);
  3215. this.valueOnOpen = val;
  3216. }
  3217. },
  3218. emitInput: function emitInput(val) {
  3219. var formatted = this.formatToValue(val);
  3220. if (!valueEquals(this.value, formatted)) {
  3221. this.$emit('input', formatted);
  3222. }
  3223. },
  3224. isValidValue: function isValidValue(value) {
  3225. if (!this.picker) {
  3226. this.mountPicker();
  3227. }
  3228. if (this.picker.isValidValue) {
  3229. return value && this.picker.isValidValue(value);
  3230. } else {
  3231. return true;
  3232. }
  3233. }
  3234. }
  3235. };
  3236. /***/ }),
  3237. /***/ 29:
  3238. /***/ (function(module, exports) {
  3239. module.exports = require("element-ui/lib/utils/date");
  3240. /***/ }),
  3241. /***/ 3:
  3242. /***/ (function(module, exports) {
  3243. module.exports = require("element-ui/lib/utils/dom");
  3244. /***/ }),
  3245. /***/ 30:
  3246. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3247. "use strict";
  3248. var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (!_vm.ranged)?_c('el-input',_vm._b({directives:[{name:"clickoutside",rawName:"v-clickoutside",value:(_vm.handleClose),expression:"handleClose"}],ref:"reference",staticClass:"el-date-editor",class:'el-date-editor--' + _vm.type,attrs:{"readonly":!_vm.editable || _vm.readonly || _vm.type === 'dates',"disabled":_vm.pickerDisabled,"size":_vm.pickerSize,"name":_vm.name,"placeholder":_vm.placeholder,"value":_vm.displayValue,"validateEvent":false},on:{"focus":_vm.handleFocus,"input":function (value) { return _vm.userInput = value; },"change":_vm.handleChange},nativeOn:{"keydown":function($event){_vm.handleKeydown($event)},"mouseenter":function($event){_vm.handleMouseEnter($event)},"mouseleave":function($event){_vm.showClose = false}}},'el-input',_vm.firstInputId,false),[_c('i',{staticClass:"el-input__icon",class:_vm.triggerClass,attrs:{"slot":"prefix"},on:{"click":_vm.handleFocus},slot:"prefix"}),(_vm.haveTrigger)?_c('i',{staticClass:"el-input__icon",class:[_vm.showClose ? '' + _vm.clearIcon : ''],attrs:{"slot":"suffix"},on:{"click":_vm.handleClickIcon},slot:"suffix"}):_vm._e()]):_c('div',{directives:[{name:"clickoutside",rawName:"v-clickoutside",value:(_vm.handleClose),expression:"handleClose"}],ref:"reference",staticClass:"el-date-editor el-range-editor el-input__inner",class:[
  3249. 'el-date-editor--' + _vm.type,
  3250. _vm.pickerSize ? ("el-range-editor--" + _vm.pickerSize) : '',
  3251. _vm.pickerDisabled ? 'is-disabled' : '',
  3252. _vm.pickerVisible ? 'is-active' : ''
  3253. ],on:{"click":_vm.handleRangeClick,"mouseenter":_vm.handleMouseEnter,"mouseleave":function($event){_vm.showClose = false},"keydown":_vm.handleKeydown}},[_c('i',{class:['el-input__icon', 'el-range__icon', _vm.triggerClass]}),_c('input',_vm._b({staticClass:"el-range-input",attrs:{"autocomplete":"off","placeholder":_vm.startPlaceholder,"disabled":_vm.pickerDisabled,"readonly":!_vm.editable || _vm.readonly,"name":_vm.name && _vm.name[0]},domProps:{"value":_vm.displayValue && _vm.displayValue[0]},on:{"input":_vm.handleStartInput,"change":_vm.handleStartChange,"focus":_vm.handleFocus}},'input',_vm.firstInputId,false)),_vm._t("range-separator",[_c('span',{staticClass:"el-range-separator"},[_vm._v(_vm._s(_vm.rangeSeparator))])]),_c('input',_vm._b({staticClass:"el-range-input",attrs:{"autocomplete":"off","placeholder":_vm.endPlaceholder,"disabled":_vm.pickerDisabled,"readonly":!_vm.editable || _vm.readonly,"name":_vm.name && _vm.name[1]},domProps:{"value":_vm.displayValue && _vm.displayValue[1]},on:{"input":_vm.handleEndInput,"change":_vm.handleEndChange,"focus":_vm.handleFocus}},'input',_vm.secondInputId,false)),(_vm.haveTrigger)?_c('i',{staticClass:"el-input__icon el-range__close-icon",class:[_vm.showClose ? '' + _vm.clearIcon : ''],on:{"click":_vm.handleClickIcon}}):_vm._e()],2)}
  3254. var staticRenderFns = []
  3255. var esExports = { render: render, staticRenderFns: staticRenderFns }
  3256. /* harmony default export */ __webpack_exports__["a"] = (esExports);
  3257. /***/ }),
  3258. /***/ 31:
  3259. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3260. "use strict";
  3261. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  3262. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_time_vue__ = __webpack_require__(41);
  3263. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_time_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_time_vue__);
  3264. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_3ea87726_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_time_vue__ = __webpack_require__(44);
  3265. var normalizeComponent = __webpack_require__(0)
  3266. /* script */
  3267. /* template */
  3268. /* template functional */
  3269. var __vue_template_functional__ = false
  3270. /* styles */
  3271. var __vue_styles__ = null
  3272. /* scopeId */
  3273. var __vue_scopeId__ = null
  3274. /* moduleIdentifier (server only) */
  3275. var __vue_module_identifier__ = null
  3276. var Component = normalizeComponent(
  3277. __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_time_vue___default.a,
  3278. __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_3ea87726_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_time_vue__["a" /* default */],
  3279. __vue_template_functional__,
  3280. __vue_styles__,
  3281. __vue_scopeId__,
  3282. __vue_module_identifier__
  3283. )
  3284. /* harmony default export */ __webpack_exports__["default"] = (Component.exports);
  3285. /***/ }),
  3286. /***/ 32:
  3287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3288. "use strict";
  3289. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  3290. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_time_spinner_vue__ = __webpack_require__(42);
  3291. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_time_spinner_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_time_spinner_vue__);
  3292. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_3673a788_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_time_spinner_vue__ = __webpack_require__(43);
  3293. var normalizeComponent = __webpack_require__(0)
  3294. /* script */
  3295. /* template */
  3296. /* template functional */
  3297. var __vue_template_functional__ = false
  3298. /* styles */
  3299. var __vue_styles__ = null
  3300. /* scopeId */
  3301. var __vue_scopeId__ = null
  3302. /* moduleIdentifier (server only) */
  3303. var __vue_module_identifier__ = null
  3304. var Component = normalizeComponent(
  3305. __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_time_spinner_vue___default.a,
  3306. __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_3673a788_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_time_spinner_vue__["a" /* default */],
  3307. __vue_template_functional__,
  3308. __vue_styles__,
  3309. __vue_scopeId__,
  3310. __vue_module_identifier__
  3311. )
  3312. /* harmony default export */ __webpack_exports__["default"] = (Component.exports);
  3313. /***/ }),
  3314. /***/ 4:
  3315. /***/ (function(module, exports) {
  3316. module.exports = require("vue");
  3317. /***/ }),
  3318. /***/ 41:
  3319. /***/ (function(module, exports, __webpack_require__) {
  3320. "use strict";
  3321. exports.__esModule = true;
  3322. var _util = __webpack_require__(11);
  3323. var _locale = __webpack_require__(5);
  3324. var _locale2 = _interopRequireDefault(_locale);
  3325. var _timeSpinner = __webpack_require__(32);
  3326. var _timeSpinner2 = _interopRequireDefault(_timeSpinner);
  3327. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3328. exports.default = {
  3329. mixins: [_locale2.default],
  3330. components: {
  3331. TimeSpinner: _timeSpinner2.default
  3332. },
  3333. props: {
  3334. visible: Boolean,
  3335. timeArrowControl: Boolean
  3336. },
  3337. watch: {
  3338. visible: function visible(val) {
  3339. var _this = this;
  3340. if (val) {
  3341. this.oldValue = this.value;
  3342. this.$nextTick(function () {
  3343. return _this.$refs.spinner.emitSelectRange('hours');
  3344. });
  3345. } else {
  3346. this.needInitAdjust = true;
  3347. }
  3348. },
  3349. value: function value(newVal) {
  3350. var _this2 = this;
  3351. var date = void 0;
  3352. if (newVal instanceof Date) {
  3353. date = (0, _util.limitTimeRange)(newVal, this.selectableRange, this.format);
  3354. } else if (!newVal) {
  3355. date = this.defaultValue ? new Date(this.defaultValue) : new Date();
  3356. }
  3357. this.date = date;
  3358. if (this.visible && this.needInitAdjust) {
  3359. this.$nextTick(function (_) {
  3360. return _this2.adjustSpinners();
  3361. });
  3362. this.needInitAdjust = false;
  3363. }
  3364. },
  3365. selectableRange: function selectableRange(val) {
  3366. this.$refs.spinner.selectableRange = val;
  3367. },
  3368. defaultValue: function defaultValue(val) {
  3369. if (!(0, _util.isDate)(this.value)) {
  3370. this.date = val ? new Date(val) : new Date();
  3371. }
  3372. }
  3373. },
  3374. data: function data() {
  3375. return {
  3376. popperClass: '',
  3377. format: 'HH:mm:ss',
  3378. value: '',
  3379. defaultValue: null,
  3380. date: new Date(),
  3381. oldValue: new Date(),
  3382. selectableRange: [],
  3383. selectionRange: [0, 2],
  3384. disabled: false,
  3385. arrowControl: false,
  3386. needInitAdjust: true
  3387. };
  3388. },
  3389. computed: {
  3390. showSeconds: function showSeconds() {
  3391. return (this.format || '').indexOf('ss') !== -1;
  3392. },
  3393. useArrow: function useArrow() {
  3394. return this.arrowControl || this.timeArrowControl || false;
  3395. },
  3396. amPmMode: function amPmMode() {
  3397. if ((this.format || '').indexOf('A') !== -1) return 'A';
  3398. if ((this.format || '').indexOf('a') !== -1) return 'a';
  3399. return '';
  3400. }
  3401. },
  3402. methods: {
  3403. handleCancel: function handleCancel() {
  3404. this.$emit('pick', this.oldValue, false);
  3405. },
  3406. handleChange: function handleChange(date) {
  3407. // this.visible avoids edge cases, when use scrolls during panel closing animation
  3408. if (this.visible) {
  3409. this.date = (0, _util.clearMilliseconds)(date);
  3410. // if date is out of range, do not emit
  3411. if (this.isValidValue(this.date)) {
  3412. this.$emit('pick', this.date, true);
  3413. }
  3414. }
  3415. },
  3416. setSelectionRange: function setSelectionRange(start, end) {
  3417. this.$emit('select-range', start, end);
  3418. this.selectionRange = [start, end];
  3419. },
  3420. handleConfirm: function handleConfirm() {
  3421. var visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3422. var first = arguments[1];
  3423. if (first) return;
  3424. var date = (0, _util.clearMilliseconds)((0, _util.limitTimeRange)(this.date, this.selectableRange, this.format));
  3425. this.$emit('pick', date, visible, first);
  3426. },
  3427. handleKeydown: function handleKeydown(event) {
  3428. var keyCode = event.keyCode;
  3429. var mapping = { 38: -1, 40: 1, 37: -1, 39: 1 };
  3430. // Left or Right
  3431. if (keyCode === 37 || keyCode === 39) {
  3432. var step = mapping[keyCode];
  3433. this.changeSelectionRange(step);
  3434. event.preventDefault();
  3435. return;
  3436. }
  3437. // Up or Down
  3438. if (keyCode === 38 || keyCode === 40) {
  3439. var _step = mapping[keyCode];
  3440. this.$refs.spinner.scrollDown(_step);
  3441. event.preventDefault();
  3442. return;
  3443. }
  3444. },
  3445. isValidValue: function isValidValue(date) {
  3446. return (0, _util.timeWithinRange)(date, this.selectableRange, this.format);
  3447. },
  3448. adjustSpinners: function adjustSpinners() {
  3449. return this.$refs.spinner.adjustSpinners();
  3450. },
  3451. changeSelectionRange: function changeSelectionRange(step) {
  3452. var list = [0, 3].concat(this.showSeconds ? [6] : []);
  3453. var mapping = ['hours', 'minutes'].concat(this.showSeconds ? ['seconds'] : []);
  3454. var index = list.indexOf(this.selectionRange[0]);
  3455. var next = (index + step + list.length) % list.length;
  3456. this.$refs.spinner.emitSelectRange(mapping[next]);
  3457. }
  3458. },
  3459. mounted: function mounted() {
  3460. var _this3 = this;
  3461. this.$nextTick(function () {
  3462. return _this3.handleConfirm(true, true);
  3463. });
  3464. this.$emit('mounted');
  3465. }
  3466. }; //
  3467. //
  3468. //
  3469. //
  3470. //
  3471. //
  3472. //
  3473. //
  3474. //
  3475. //
  3476. //
  3477. //
  3478. //
  3479. //
  3480. //
  3481. //
  3482. //
  3483. //
  3484. //
  3485. //
  3486. //
  3487. //
  3488. //
  3489. //
  3490. //
  3491. //
  3492. //
  3493. //
  3494. //
  3495. //
  3496. //
  3497. //
  3498. /***/ }),
  3499. /***/ 42:
  3500. /***/ (function(module, exports, __webpack_require__) {
  3501. "use strict";
  3502. exports.__esModule = true;
  3503. var _util = __webpack_require__(11);
  3504. var _scrollbar = __webpack_require__(17);
  3505. var _scrollbar2 = _interopRequireDefault(_scrollbar);
  3506. var _repeatClick = __webpack_require__(24);
  3507. var _repeatClick2 = _interopRequireDefault(_repeatClick);
  3508. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3509. exports.default = {
  3510. components: { ElScrollbar: _scrollbar2.default },
  3511. directives: {
  3512. repeatClick: _repeatClick2.default
  3513. },
  3514. props: {
  3515. date: {},
  3516. defaultValue: {}, // reserved for future use
  3517. showSeconds: {
  3518. type: Boolean,
  3519. default: true
  3520. },
  3521. arrowControl: Boolean,
  3522. amPmMode: {
  3523. type: String,
  3524. default: '' // 'a': am/pm; 'A': AM/PM
  3525. }
  3526. },
  3527. computed: {
  3528. hours: function hours() {
  3529. return this.date.getHours();
  3530. },
  3531. minutes: function minutes() {
  3532. return this.date.getMinutes();
  3533. },
  3534. seconds: function seconds() {
  3535. return this.date.getSeconds();
  3536. },
  3537. hoursList: function hoursList() {
  3538. return (0, _util.getRangeHours)(this.selectableRange);
  3539. },
  3540. minutesList: function minutesList() {
  3541. return (0, _util.getRangeMinutes)(this.selectableRange, this.hours);
  3542. },
  3543. arrowHourList: function arrowHourList() {
  3544. var hours = this.hours;
  3545. return [hours > 0 ? hours - 1 : undefined, hours, hours < 23 ? hours + 1 : undefined];
  3546. },
  3547. arrowMinuteList: function arrowMinuteList() {
  3548. var minutes = this.minutes;
  3549. return [minutes > 0 ? minutes - 1 : undefined, minutes, minutes < 59 ? minutes + 1 : undefined];
  3550. },
  3551. arrowSecondList: function arrowSecondList() {
  3552. var seconds = this.seconds;
  3553. return [seconds > 0 ? seconds - 1 : undefined, seconds, seconds < 59 ? seconds + 1 : undefined];
  3554. }
  3555. },
  3556. data: function data() {
  3557. return {
  3558. selectableRange: [],
  3559. currentScrollbar: null
  3560. };
  3561. },
  3562. mounted: function mounted() {
  3563. var _this = this;
  3564. this.$nextTick(function () {
  3565. !_this.arrowControl && _this.bindScrollEvent();
  3566. });
  3567. },
  3568. methods: {
  3569. increase: function increase() {
  3570. this.scrollDown(1);
  3571. },
  3572. decrease: function decrease() {
  3573. this.scrollDown(-1);
  3574. },
  3575. modifyDateField: function modifyDateField(type, value) {
  3576. switch (type) {
  3577. case 'hours':
  3578. this.$emit('change', (0, _util.modifyTime)(this.date, value, this.minutes, this.seconds));break;
  3579. case 'minutes':
  3580. this.$emit('change', (0, _util.modifyTime)(this.date, this.hours, value, this.seconds));break;
  3581. case 'seconds':
  3582. this.$emit('change', (0, _util.modifyTime)(this.date, this.hours, this.minutes, value));break;
  3583. }
  3584. },
  3585. handleClick: function handleClick(type, _ref) {
  3586. var value = _ref.value,
  3587. disabled = _ref.disabled;
  3588. if (!disabled) {
  3589. this.modifyDateField(type, value);
  3590. this.emitSelectRange(type);
  3591. this.adjustSpinner(type, value);
  3592. }
  3593. },
  3594. emitSelectRange: function emitSelectRange(type) {
  3595. if (type === 'hours') {
  3596. this.$emit('select-range', 0, 2);
  3597. } else if (type === 'minutes') {
  3598. this.$emit('select-range', 3, 5);
  3599. } else if (type === 'seconds') {
  3600. this.$emit('select-range', 6, 8);
  3601. }
  3602. this.currentScrollbar = type;
  3603. },
  3604. bindScrollEvent: function bindScrollEvent() {
  3605. var _this2 = this;
  3606. var bindFuntion = function bindFuntion(type) {
  3607. _this2.$refs[type].wrap.onscroll = function (e) {
  3608. // TODO: scroll is emitted when set scrollTop programatically
  3609. // should find better solutions in the future!
  3610. _this2.handleScroll(type, e);
  3611. };
  3612. };
  3613. bindFuntion('hours');
  3614. bindFuntion('minutes');
  3615. bindFuntion('seconds');
  3616. },
  3617. handleScroll: function handleScroll(type) {
  3618. var value = Math.min(Math.floor((this.$refs[type].wrap.scrollTop - (this.scrollBarHeight(type) * 0.5 - 10) / this.typeItemHeight(type) + 3) / this.typeItemHeight(type)), type === 'hours' ? 23 : 59);
  3619. this.modifyDateField(type, value);
  3620. },
  3621. // NOTE: used by datetime / date-range panel
  3622. // renamed from adjustScrollTop
  3623. // should try to refactory it
  3624. adjustSpinners: function adjustSpinners() {
  3625. this.adjustSpinner('hours', this.hours);
  3626. this.adjustSpinner('minutes', this.minutes);
  3627. this.adjustSpinner('seconds', this.seconds);
  3628. },
  3629. adjustCurrentSpinner: function adjustCurrentSpinner(type) {
  3630. this.adjustSpinner(type, this[type]);
  3631. },
  3632. adjustSpinner: function adjustSpinner(type, value) {
  3633. if (this.arrowControl) return;
  3634. var el = this.$refs[type].wrap;
  3635. if (el) {
  3636. el.scrollTop = Math.max(0, value * this.typeItemHeight(type));
  3637. }
  3638. },
  3639. scrollDown: function scrollDown(step) {
  3640. if (!this.currentScrollbar) {
  3641. this.emitSelectRange('hours');
  3642. }
  3643. var label = this.currentScrollbar;
  3644. var hoursList = this.hoursList;
  3645. var now = this[label];
  3646. if (this.currentScrollbar === 'hours') {
  3647. var total = Math.abs(step);
  3648. step = step > 0 ? 1 : -1;
  3649. var length = hoursList.length;
  3650. while (length-- && total) {
  3651. now = (now + step + hoursList.length) % hoursList.length;
  3652. if (hoursList[now]) {
  3653. continue;
  3654. }
  3655. total--;
  3656. }
  3657. if (hoursList[now]) return;
  3658. } else {
  3659. now = (now + step + 60) % 60;
  3660. }
  3661. this.modifyDateField(label, now);
  3662. this.adjustSpinner(label, now);
  3663. },
  3664. amPm: function amPm(hour) {
  3665. var shouldShowAmPm = this.amPmMode.toLowerCase() === 'a';
  3666. if (!shouldShowAmPm) return '';
  3667. var isCapital = this.amPmMode === 'A';
  3668. var content = hour < 12 ? ' am' : ' pm';
  3669. if (isCapital) content = content.toUpperCase();
  3670. return content;
  3671. },
  3672. typeItemHeight: function typeItemHeight(type) {
  3673. return this.$refs[type].$el.querySelector('li').offsetHeight;
  3674. },
  3675. scrollBarHeight: function scrollBarHeight(type) {
  3676. return this.$refs[type].$el.offsetHeight;
  3677. }
  3678. }
  3679. }; //
  3680. //
  3681. //
  3682. //
  3683. //
  3684. //
  3685. //
  3686. //
  3687. //
  3688. //
  3689. //
  3690. //
  3691. //
  3692. //
  3693. //
  3694. //
  3695. //
  3696. //
  3697. //
  3698. //
  3699. //
  3700. //
  3701. //
  3702. //
  3703. //
  3704. //
  3705. //
  3706. //
  3707. //
  3708. //
  3709. //
  3710. //
  3711. //
  3712. //
  3713. //
  3714. //
  3715. //
  3716. //
  3717. //
  3718. //
  3719. //
  3720. //
  3721. //
  3722. //
  3723. //
  3724. //
  3725. //
  3726. //
  3727. //
  3728. //
  3729. //
  3730. //
  3731. //
  3732. //
  3733. //
  3734. //
  3735. //
  3736. //
  3737. //
  3738. //
  3739. //
  3740. //
  3741. //
  3742. //
  3743. //
  3744. //
  3745. //
  3746. //
  3747. //
  3748. //
  3749. //
  3750. //
  3751. //
  3752. //
  3753. //
  3754. //
  3755. //
  3756. //
  3757. //
  3758. //
  3759. //
  3760. //
  3761. //
  3762. //
  3763. //
  3764. //
  3765. //
  3766. //
  3767. //
  3768. //
  3769. //
  3770. //
  3771. //
  3772. //
  3773. //
  3774. //
  3775. //
  3776. //
  3777. //
  3778. //
  3779. /***/ }),
  3780. /***/ 43:
  3781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3782. "use strict";
  3783. var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"el-time-spinner",class:{ 'has-seconds': _vm.showSeconds }},[(!_vm.arrowControl)?[_c('el-scrollbar',{ref:"hours",staticClass:"el-time-spinner__wrapper",attrs:{"wrap-style":"max-height: inherit;","view-class":"el-time-spinner__list","noresize":"","tag":"ul"},nativeOn:{"mouseenter":function($event){_vm.emitSelectRange('hours')},"mousemove":function($event){_vm.adjustCurrentSpinner('hours')}}},_vm._l((_vm.hoursList),function(disabled,hour){return _c('li',{staticClass:"el-time-spinner__item",class:{ 'active': hour === _vm.hours, 'disabled': disabled },on:{"click":function($event){_vm.handleClick('hours', { value: hour, disabled: disabled })}}},[_vm._v(_vm._s(('0' + (_vm.amPmMode ? (hour % 12 || 12) : hour )).slice(-2))+_vm._s(_vm.amPm(hour)))])})),_c('el-scrollbar',{ref:"minutes",staticClass:"el-time-spinner__wrapper",attrs:{"wrap-style":"max-height: inherit;","view-class":"el-time-spinner__list","noresize":"","tag":"ul"},nativeOn:{"mouseenter":function($event){_vm.emitSelectRange('minutes')},"mousemove":function($event){_vm.adjustCurrentSpinner('minutes')}}},_vm._l((_vm.minutesList),function(enabled,key){return _c('li',{staticClass:"el-time-spinner__item",class:{ 'active': key === _vm.minutes, disabled: !enabled },on:{"click":function($event){_vm.handleClick('minutes', { value: key, disabled: false })}}},[_vm._v(_vm._s(('0' + key).slice(-2)))])})),_c('el-scrollbar',{directives:[{name:"show",rawName:"v-show",value:(_vm.showSeconds),expression:"showSeconds"}],ref:"seconds",staticClass:"el-time-spinner__wrapper",attrs:{"wrap-style":"max-height: inherit;","view-class":"el-time-spinner__list","noresize":"","tag":"ul"},nativeOn:{"mouseenter":function($event){_vm.emitSelectRange('seconds')},"mousemove":function($event){_vm.adjustCurrentSpinner('seconds')}}},_vm._l((60),function(second,key){return _c('li',{key:key,staticClass:"el-time-spinner__item",class:{ 'active': key === _vm.seconds },on:{"click":function($event){_vm.handleClick('seconds', { value: key, disabled: false })}}},[_vm._v(_vm._s(('0' + key).slice(-2)))])}))]:_vm._e(),(_vm.arrowControl)?[_c('div',{staticClass:"el-time-spinner__wrapper is-arrow",on:{"mouseenter":function($event){_vm.emitSelectRange('hours')}}},[_c('i',{directives:[{name:"repeat-click",rawName:"v-repeat-click",value:(_vm.decrease),expression:"decrease"}],staticClass:"el-time-spinner__arrow el-icon-arrow-up"}),_c('i',{directives:[{name:"repeat-click",rawName:"v-repeat-click",value:(_vm.increase),expression:"increase"}],staticClass:"el-time-spinner__arrow el-icon-arrow-down"}),_c('ul',{ref:"hours",staticClass:"el-time-spinner__list"},_vm._l((_vm.arrowHourList),function(hour,key){return _c('li',{key:key,staticClass:"el-time-spinner__item",class:{ 'active': hour === _vm.hours, 'disabled': _vm.hoursList[hour] }},[_vm._v(_vm._s(hour === undefined ? '' : ('0' + (_vm.amPmMode ? (hour % 12 || 12) : hour )).slice(-2) + _vm.amPm(hour)))])}))]),_c('div',{staticClass:"el-time-spinner__wrapper is-arrow",on:{"mouseenter":function($event){_vm.emitSelectRange('minutes')}}},[_c('i',{directives:[{name:"repeat-click",rawName:"v-repeat-click",value:(_vm.decrease),expression:"decrease"}],staticClass:"el-time-spinner__arrow el-icon-arrow-up"}),_c('i',{directives:[{name:"repeat-click",rawName:"v-repeat-click",value:(_vm.increase),expression:"increase"}],staticClass:"el-time-spinner__arrow el-icon-arrow-down"}),_c('ul',{ref:"minutes",staticClass:"el-time-spinner__list"},_vm._l((_vm.arrowMinuteList),function(minute,key){return _c('li',{key:key,staticClass:"el-time-spinner__item",class:{ 'active': minute === _vm.minutes }},[_vm._v("\n "+_vm._s(minute === undefined ? '' : ('0' + minute).slice(-2))+"\n ")])}))]),(_vm.showSeconds)?_c('div',{staticClass:"el-time-spinner__wrapper is-arrow",on:{"mouseenter":function($event){_vm.emitSelectRange('seconds')}}},[_c('i',{directives:[{name:"repeat-click",rawName:"v-repeat-click",value:(_vm.decrease),expression:"decrease"}],staticClass:"el-time-spinner__arrow el-icon-arrow-up"}),_c('i',{directives:[{name:"repeat-click",rawName:"v-repeat-click",value:(_vm.increase),expression:"increase"}],staticClass:"el-time-spinner__arrow el-icon-arrow-down"}),_c('ul',{ref:"seconds",staticClass:"el-time-spinner__list"},_vm._l((_vm.arrowSecondList),function(second,key){return _c('li',{key:key,staticClass:"el-time-spinner__item",class:{ 'active': second === _vm.seconds }},[_vm._v("\n "+_vm._s(second === undefined ? '' : ('0' + second).slice(-2))+"\n ")])}))]):_vm._e()]:_vm._e()],2)}
  3784. var staticRenderFns = []
  3785. var esExports = { render: render, staticRenderFns: staticRenderFns }
  3786. /* harmony default export */ __webpack_exports__["a"] = (esExports);
  3787. /***/ }),
  3788. /***/ 44:
  3789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3790. "use strict";
  3791. var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('transition',{attrs:{"name":"el-zoom-in-top"},on:{"after-leave":function($event){_vm.$emit('dodestroy')}}},[_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.visible),expression:"visible"}],staticClass:"el-time-panel el-popper",class:_vm.popperClass},[_c('div',{staticClass:"el-time-panel__content",class:{ 'has-seconds': _vm.showSeconds }},[_c('time-spinner',{ref:"spinner",attrs:{"arrow-control":_vm.useArrow,"show-seconds":_vm.showSeconds,"am-pm-mode":_vm.amPmMode,"date":_vm.date},on:{"change":_vm.handleChange,"select-range":_vm.setSelectionRange}})],1),_c('div',{staticClass:"el-time-panel__footer"},[_c('button',{staticClass:"el-time-panel__btn cancel",attrs:{"type":"button"},on:{"click":_vm.handleCancel}},[_vm._v(_vm._s(_vm.t('el.datepicker.cancel')))]),_c('button',{staticClass:"el-time-panel__btn",class:{confirm: !_vm.disabled},attrs:{"type":"button"},on:{"click":function($event){_vm.handleConfirm()}}},[_vm._v(_vm._s(_vm.t('el.datepicker.confirm')))])])])])}
  3792. var staticRenderFns = []
  3793. var esExports = { render: render, staticRenderFns: staticRenderFns }
  3794. /* harmony default export */ __webpack_exports__["a"] = (esExports);
  3795. /***/ }),
  3796. /***/ 49:
  3797. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3798. "use strict";
  3799. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  3800. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_date_table_vue__ = __webpack_require__(186);
  3801. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_date_table_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_date_table_vue__);
  3802. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_ecbc1fc4_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_date_table_vue__ = __webpack_require__(187);
  3803. var normalizeComponent = __webpack_require__(0)
  3804. /* script */
  3805. /* template */
  3806. /* template functional */
  3807. var __vue_template_functional__ = false
  3808. /* styles */
  3809. var __vue_styles__ = null
  3810. /* scopeId */
  3811. var __vue_scopeId__ = null
  3812. /* moduleIdentifier (server only) */
  3813. var __vue_module_identifier__ = null
  3814. var Component = normalizeComponent(
  3815. __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_date_table_vue___default.a,
  3816. __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_ecbc1fc4_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_date_table_vue__["a" /* default */],
  3817. __vue_template_functional__,
  3818. __vue_styles__,
  3819. __vue_scopeId__,
  3820. __vue_module_identifier__
  3821. )
  3822. /* harmony default export */ __webpack_exports__["default"] = (Component.exports);
  3823. /***/ }),
  3824. /***/ 5:
  3825. /***/ (function(module, exports) {
  3826. module.exports = require("element-ui/lib/mixins/locale");
  3827. /***/ }),
  3828. /***/ 6:
  3829. /***/ (function(module, exports) {
  3830. module.exports = require("element-ui/lib/input");
  3831. /***/ }),
  3832. /***/ 7:
  3833. /***/ (function(module, exports) {
  3834. module.exports = require("element-ui/lib/utils/vue-popper");
  3835. /***/ }),
  3836. /***/ 9:
  3837. /***/ (function(module, exports) {
  3838. module.exports = require("element-ui/lib/utils/merge");
  3839. /***/ })
  3840. /******/ });