h_ui
Version:
A Vue.js 2.0 UI Components Framework
1 lines • 18.5 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("h_ui/dist/lib/util/global.js"),require("h_ui/dist/lib/Icon.js"),require("h_ui/dist/lib/mixins/locale.js"),require("h_ui/dist/lib/Button.js"),require("h_ui/dist/lib/directives/clickoutside.js"),require("h_ui/dist/lib/Calendar.js")):"function"==typeof define&&define.amd?define("h_ui/lib",["h_ui/dist/lib/util/global.js","h_ui/dist/lib/Icon.js","h_ui/dist/lib/mixins/locale.js","h_ui/dist/lib/Button.js","h_ui/dist/lib/directives/clickoutside.js","h_ui/dist/lib/Calendar.js"],t):"object"==typeof exports?exports["h_ui/lib"]=t(require("h_ui/dist/lib/util/global.js"),require("h_ui/dist/lib/Icon.js"),require("h_ui/dist/lib/mixins/locale.js"),require("h_ui/dist/lib/Button.js"),require("h_ui/dist/lib/directives/clickoutside.js"),require("h_ui/dist/lib/Calendar.js")):e["h_ui/lib"]=t(e["h_ui/dist/lib/util/global.js"],e["h_ui/dist/lib/Icon.js"],e["h_ui/dist/lib/mixins/locale.js"],e["h_ui/dist/lib/Button.js"],e["h_ui/dist/lib/directives/clickoutside.js"],e["h_ui/dist/lib/Calendar.js"])}(window,(function(e,t,n,r,i,o){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/lib/",n(n.s=988)}({0:function(e,t){var n=e.exports={version:"2.6.12"};"number"==typeof __e&&(__e=n)},1:function(e,t){var n=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},10:function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},11:function(e,t,n){var r=n(5),i=n(14);e.exports=n(2)?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},119:function(e,t){e.exports=r},12:function(e,t,n){var r=n(6);e.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},124:function(e,t){e.exports=i},14:function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},15:function(e,t,n){var r=n(38);e.exports=function(e,t,n){return t in e?r(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},16:function(e,t,n){var r=n(27);e.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},17:function(e,t,n){var r=n(6);e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;if("function"==typeof(n=e.valueOf)&&!r(i=n.call(e)))return i;if(!t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},18:function(e,t){e.exports=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e}},2:function(e,t,n){e.exports=!n(7)((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))},24:function(e,t,n){var r=n(6),i=n(1).document,o=r(i)&&r(i.createElement);e.exports=function(e){return o?i.createElement(e):{}}},25:function(e,t,n){e.exports=!n(2)&&!n(7)((function(){return 7!=Object.defineProperty(n(24)("div"),"a",{get:function(){return 7}}).a}))},27:function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},3:function(e,t,n){var r=n(1),i=n(0),o=n(16),a=n(11),l=n(10),u=function(e,t,n){var s,c,d,f=e&u.F,h=e&u.G,p=e&u.S,v=e&u.P,y=e&u.B,g=e&u.W,w=h?i:i[t]||(i[t]={}),x=w.prototype,_=h?r:p?r[t]:(r[t]||{}).prototype;for(s in h&&(n=t),n)(c=!f&&_&&void 0!==_[s])&&l(w,s)||(d=c?_[s]:n[s],w[s]=h&&"function"!=typeof _[s]?n[s]:y&&c?o(d,r):g&&_[s]==d?function(e){var t=function(t,n,r){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,r)}return e.apply(this,arguments)};return t.prototype=e.prototype,t}(d):v&&"function"==typeof d?o(Function.call,d):d,v&&((w.virtual||(w.virtual={}))[s]=d,e&u.R&&x&&!x[s]&&a(x,s,d)))};u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,e.exports=u},32:function(t,n){t.exports=e},35:function(e,t){e.exports="\t\n\v\f\r \u2028\u2029\ufeff"},38:function(e,t,n){e.exports=n(39)},39:function(e,t,n){n(40);var r=n(0).Object;e.exports=function(e,t,n){return r.defineProperty(e,t,n)}},4:function(e,t,n){"use strict";function r(e,t,n,r,i,o,a,l){var u,s="function"==typeof e?e.options:e;if(t&&(s.render=t,s.staticRenderFns=n,s._compiled=!0),r&&(s.functional=!0),o&&(s._scopeId="data-v-"+o),a?(u=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),i&&i.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(a)},s._ssrRegister=u):i&&(u=l?function(){i.call(this,(s.functional?this.parent:this).$root.$options.shadowRoot)}:i),u)if(s.functional){s._injectStyles=u;var c=s.render;s.render=function(e,t){return u.call(t),c(e,t)}}else{var d=s.beforeCreate;s.beforeCreate=d?[].concat(d,u):[u]}return{exports:e,options:s}}n.d(t,"a",(function(){return r}))},40:function(e,t,n){var r=n(3);r(r.S+r.F*!n(2),"Object",{defineProperty:n(5).f})},47:function(e,n){e.exports=t},49:function(e,t){e.exports=n},5:function(e,t,n){var r=n(12),i=n(25),o=n(17),a=Object.defineProperty;t.f=n(2)?Object.defineProperty:function(e,t,n){if(r(e),t=o(t,!0),r(n),i)try{return a(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(e[t]=n.value),e}},51:function(e,t,n){var r=n(3),i=n(18),o=n(7),a=n(35),l="["+a+"]",u=RegExp("^"+l+l+"*"),s=RegExp(l+l+"*$"),c=function(e,t,n){var i={},l=o((function(){return!!a[e]()||"
"!="
"[e]()})),u=i[e]=l?t(d):a[e];n&&(i[n]=u),r(r.P+r.F*l,"String",i)},d=c.trim=function(e,t){return e=String(i(e)),1&t&&(e=e.replace(u,"")),2&t&&(e=e.replace(s,"")),e};e.exports=c},53:function(e,t,n){e.exports=n(69)},533:function(e,t,n){"use strict";n.r(t);var r=n(534),i=n.n(r);for(var o in r)["default"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(o);t.default=i.a},534:function(e,t,n){"use strict";var r=n(8);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=r(n(15)),o=r(n(53)),a=r(n(85)),l=r(n(990)),u=r(n(47)),s=r(n(49)),c=r(n(119)),d=r(n(124)),f=c.default.Group,h="h-schedule",p={name:"Schedule",components:{Calendar:l.default,Icon:u.default,hButton:c.default,hButtonGroup:f},mixins:[s.default],directives:{clickoutside:d.default},props:{events:{type:Array,default:function(){return[]}},cell:{type:Object,default:function(){return{cellWidth:0,cellHeight:0}}},circleEvent:{type:Boolean,default:!1},showTitle:{type:Boolean,default:!1},showEventItemCircle:{type:Boolean,default:!1}},data:function(){return{curYear:(new Date).getFullYear(),curMonth:(new Date).getMonth()+1,prefixCls:h,isShowMore:!1,viewDate:"",viewCoord:{x:0,y:0},showMoreDateIndex:0,topPosition:"136px",itemPaddingTop:null,popoverPositionLeft:!0}},computed:{showEvtNum:function(){return 0===this.cell.cellHeight?3:(0,o.default)((this.cell.cellHeight-25)/18,10)},calendarStyle:function(){return this.cell.cellWidth?{width:"".concat(7*this.cell.cellWidth,"px")}:null},popoverStyles:function(){return this.popoverPositionLeft?{top:this.viewCoord.y,left:this.viewCoord.x}:{top:this.viewCoord.y,right:0}},eventwrapperHeight:function(){return this.cell.cellHeight?{height:"".concat(this.cell.cellHeight,"px"),paddingTop:null!==this.itemPaddingTop?"".concat(this.itemPaddingTop,"px"):null}:null},disableTodayBtn:function(){var e=new Date;return this.curYear===e.getFullYear()&&this.curMonth-1===e.getMonth()},dateEvents:function(){return this.makeDateEvents()},moreEvents:function(){var e=this.dateEvents;return e[this.showMoreDateIndex]?e[this.showMoreDateIndex].events:[]}},methods:{getEventByDate:function(e,t){return this.dateEvents.find((function(n){return null!==n&&n.date.getDate()===t&&e===n.date.getMonth()+1}))},contextMenu:function(e,t){var n=t.date,r=n.getMonth()+1,i=n.getDate();this.$emit("on-right-click",r,i,this.getEventByDate(r,i))},showPaddingTop:function(){return 0!==this.showEvtNum||(this.cell.cellHeight>=19&&(this.itemPaddingTop=this.cell.cellHeight-19),!1)},orderShow:function(e,t){if(0===this.cell.cellHeight)return!0;var n=25+18*e+19-4;return!(t.length>this.showEvtNum&&n>this.cell.cellHeight)},jumpToday:function(){this.curYear=(new Date).getFullYear(),this.curMonth=(new Date).getMonth()+1},prevMonth:function(){1===this.curMonth?(this.curYear--,this.curMonth=12):this.curMonth--},nextMonth:function(){12===this.curMonth?(this.curYear++,this.curMonth=1):this.curMonth++},prevYear:function(){this.curYear--},nextYear:function(){this.curYear++},dateStr:function(e){return e?"".concat(e.getFullYear()+this.t("i.calendar.year")).concat(e.getMonth()+1+this.t("i.calendar.monthAfter")).concat(e.getDate()+this.t("i.calendar.day")):""},timeInterval:function(e,t){var n=Date.parse(new Date(e)),r=Date.parse(new Date(t))-n,i=Math.floor(r/864e5),o=r%864e5,a=Math.floor(o/36e5),l=o%36e5,u=Math.floor(l/6e4);return{time:i+"天"+a+"时"+u+"分",days:i,hours:a,minutes:u}},makeDateEvents:function(){var e=this,t=this.events;if(0===t.length)return[];var n=this.curYear,r=this.curMonth,i=new Date(n,r-1,1),o=new Date(n,r,0);t.forEach((function(t){delete t.order;var n=JSON.parse((0,a.default)(t)),r=new Date(n.startDate),i=new Date(n.endDate),o=e.timeInterval(r,i).days;t.days=o}));for(var l=t.filter((function(e){var t=new Date(e.startDate);t=new Date(t.getFullYear(),t.getMonth(),t.getDate());var n=e.endDate?new Date(e.endDate):t;return n=new Date(n.getFullYear(),n.getMonth(),n.getDate()),t>=i&&n<=o||t<i&&n>=i||t<=o&&n>o})),u=new Array(42),s=0;s<42;)u[s++]=null;for(var c=i.getDay(),d=o.getDate()+c-1,f=function(e){var t=u[e],i=new Date(n,r-1,e-c+1);null===t&&(t=u[e]={events:[],date:i});var o=t.events;l.forEach((function(e){var t=new Date(e.startDate);t=new Date(t.getFullYear(),t.getMonth(),t.getDate());var n=e.endDate?new Date(e.endDate):t;n=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i>=t&&i<=n&&o.push(e)})),o.sort((function(e,t){return e.order?t.order?e.order-t.order:-1:1}));for(var a=0;a<o.length;a++)o[a].order=o[a].order||a+1,o[a].hidden=!1,o[a].order==a+1||a>2||o.splice(a,0,{order:a+1,hidden:!0})},h=c;h<=d;h++)f(h);return u},isStart:function(e,t){return new Date(t.startDate).toDateString()===e.date.toDateString()},isEnd:function(e,t){return(t.endDate?new Date(t.endDate):new Date(t.startDate)).toDateString()===e.date.toDateString()},isEventPlaceBegin:function(e,t){return this.isStart(e,t)||0===e.date.getDay()||1===e.date.getDate()},eventCls:function(e,t){var n;return n={},(0,i.default)(n,"".concat(h,"-event-content"),!0),(0,i.default)(n,"".concat(h,"-event-placeholder"),t.hidden),(0,i.default)(n,"event-place-start",this.isStart(e,t)),(0,i.default)(n,"event-place-end",this.isEnd(e,t)),(0,i.default)(n,"event-day-over-one",t.days>0),(0,i.default)(n,"event-day-over-begin",this.isStart(e,t)&&t.days>0),n},showMore:function(e,t){var n=this.$refs["schedule-main"].clientWidth/7,r=n>220?n:220,i=e.date.getDay();this.popoverPositionLeft=!0,(7-i)*n<r&&(this.popoverPositionLeft=!1),this.showMoreDateIndex=t,this.viewDate=this.dateStr(e.date),this.viewCoord.x=t%7*14.28+"%",this.viewCoord.y=100*Math.floor(t/7)+"px",0!==this.cell.cellHeight&&(this.viewCoord.y=Math.floor(t/7)*this.cell.cellHeight+"px"),this.isShowMore=!0},closePopup:function(){this.isShowMore=!1,this.viewDate=""},handleEvtClick:function(e){this.$emit("on-event-click",e)},handleEvtDblClick:function(e){this.$emit("on-event-dblclick",e)},handleCellClick:function(e,t){this.$emit("on-click",e,t,this.getEventByDate(e,t))},handleCellDblClick:function(e,t){this.$emit("on-dblclick",e,t,this.getEventByDate(e,t))},handleCellSelect:function(e,t){this.$emit("on-select",e,t,this.getEventByDate(e,t))},handlePanelChange:function(e,t){this.$emit("on-panel-change",e,t)},calcPopoverLength:function(e){return e.filter((function(e){return!e.hidden})).length}},mounted:function(){if(this.$slots.header){var e=this.$slots.header[0].elm.clientHeight;this.topPosition=100+e+"px"}}};t.default=p},6:function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},69:function(e,t,n){n(70),e.exports=n(0).parseInt},7:function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},70:function(e,t,n){var r=n(3),i=n(71);r(r.G+r.F*(parseInt!=i),{parseInt:i})},71:function(e,t,n){var r=n(1).parseInt,i=n(51).trim,o=n(35),a=/^[-+]?0[xX]/;e.exports=8!==r(o+"08")||22!==r(o+"0x16")?function(e,t){var n=i(String(e),3);return r(n,t>>>0||(a.test(n)?16:10))}:r},753:function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return i}));var r=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"schedule-main",class:[""+e.prefixCls],style:e.calendarStyle},[n("calendar",{ref:"calendar",style:e.calendarStyle,attrs:{"current-year":e.curYear,"current-month":e.curMonth,monthViewNum:1,multiSelect:!1,enableCtxMenu:!1,cellHeight:e.cell.cellHeight||0,cellWidth:e.cell.cellWidth||0},on:{"on-context-menu":e.contextMenu,"on-click":e.handleCellClick,"on-dblclick":e.handleCellDblClick,"on-select":e.handleCellSelect,"on-panel-change":e.handlePanelChange}},[e._t("header",[n("div",{class:[e.prefixCls+"-header"]},[n("h-button-group",[n("h-button",{attrs:{type:"primary",icon:"arrow-l",title:e.t("i.calendar.lastYear")},on:{click:e.prevYear}}),e._v(" "),n("h-button",{attrs:{type:"primary",icon:"return",title:e.t("i.calendar.lastMonth")},on:{click:e.prevMonth}}),e._v(" "),n("h-button",{attrs:{type:"primary",icon:"enter",title:e.t("i.calendar.nextMonth")},on:{click:e.nextMonth}}),e._v(" "),n("h-button",{attrs:{type:"primary",icon:"arrow-r",title:e.t("i.calendar.nextYear")},on:{click:e.nextYear}})],1),e._v(" "),n("h-button",{class:[e.prefixCls+"-today-btn"],attrs:{type:"primary",disabled:e.disableTodayBtn,title:e.dateStr(new Date)},on:{click:e.jumpToday}},[e._v(e._s(e.t("i.calendar.today")))]),e._v(" "),n("span",{class:[e.prefixCls+"-date-text"]},[e._v(e._s(""+e.curYear+e.t("i.calendar.year")+" "+e.curMonth+e.t("i.calendar.monthAfter")))])],1)],{slot:"header"})],2),e._v(" "),n("div",{class:[e.prefixCls+"-events"],style:Object.assign({},e.calendarStyle,{top:e.topPosition})},[e._l(e.dateEvents,(function(t,r){return n("div",{key:r,class:[e.prefixCls+"-event-wrapper",{"first-line":!e.circleEvent&&e.showPaddingTop()}],style:e.eventwrapperHeight},[e.circleEvent?e._e():[e._l((t||{}).events||[],(function(r,i){return n("div",{directives:[{name:"show",rawName:"v-show",value:r.order<=e.showEvtNum&&e.orderShow(r.order,t.events),expression:"\n event.order <= showEvtNum && orderShow(event.order, item.events)\n "}],key:i,class:e.eventCls(t,r),style:{backgroundColor:r.backgroundColor},attrs:{title:e.showTitle&&e.isEventPlaceBegin(t,r)?r.title:null},on:{click:function(t){return e.handleEvtClick(r)},dblclick:function(t){return e.handleEvtDblClick(r)}}},[e.isStart(t,r)&&e.showEventItemCircle?n("span",{staticClass:"event-item-circle",style:{background:r.color}}):e._e(),e._v(" "),n("span",{staticClass:"event-item-text"},[e._v(e._s(e.isEventPlaceBegin(t,r)?r.title:""))])])})),e._v(" "),null!==t&&t.events.length>e.showEvtNum?n("div",{class:[e.prefixCls+"-event-more"]},[n("Icon",{attrs:{name:"unfold"},on:{"on-click":function(n){return e.showMore(t,r)}}})],1):e._e()],e._v(" "),e.circleEvent?[n("div",{directives:[{name:"show",rawName:"v-show",value:null!==t&&t.events.length>0,expression:"item !== null && item.events.length > 0"}],staticClass:"event-circle-remind"})]:e._e()],2)})),e._v(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:e.isShowMore,expression:"isShowMore"},{name:"clickoutside",rawName:"v-clickoutside",value:{trigger:"mousedown",handler:e.closePopup},expression:"{ trigger: 'mousedown', handler: closePopup }"}],class:[e.prefixCls+"-popover"],style:e.popoverStyles},[n("div",{class:[e.prefixCls+"-popover-header"]},[n("span",[e._v(e._s(e.viewDate))]),e._v(" "),n("Icon",{attrs:{size:"12",name:"close"},on:{"on-click":e.closePopup}})],1),e._v(" "),n("div",{class:[e.prefixCls+"-popover-body"]},e._l(e.moreEvents,(function(t,r){return n("div",{key:r,class:[e.prefixCls+"-popover-body-item"],style:{display:t.hidden?"none":"flex"},attrs:{title:e.showTitle?t.title:null},on:{click:function(n){return e.handleEvtClick(t)},dblclick:function(n){return e.handleEvtDblClick(t)}}},[e.showEventItemCircle?n("span",{staticClass:"event-item-circle",style:{background:t.color}}):e._e(),e._v(" "),n("span",{staticClass:"event-item-text"},[e._v(" "+e._s(t.title))])])})),0)])],2)],1)},i=[];r._withStripped=!0},8:function(e,t){e.exports=function(e){return e&&e.__esModule?e:{default:e}},e.exports.__esModule=!0,e.exports.default=e.exports},85:function(e,t,n){e.exports=n(91)},91:function(e,t,n){var r=n(0),i=r.JSON||(r.JSON={stringify:JSON.stringify});e.exports=function(e){return i.stringify.apply(i,arguments)}},988:function(e,t,n){"use strict";var r=n(8);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=r(n(989)),o=n(32);i.default.install=function(e,t){(0,o.setGlobal)(e,t),e.component("HSchedule",i.default),e.component("Schedule",i.default)};var a=i.default;t.default=a},989:function(e,t,n){"use strict";n.r(t);var r=n(753),i=n(533);for(var o in i)["default"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var a=n(4),l=Object(a.a)(i.default,r.a,r.b,!1,null,null,null);t.default=l.exports},990:function(e,t){e.exports=o}})}));