UNPKG

vue-widget-date

Version:

基于vue仿广点通时间选择程序

2 lines 9.96 kB
webpackJsonp([1],{"7utO":function(t,e){},NHnr:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i("7+uW"),s=i("7t+N"),a=i.n(s),n=i("M4fF"),l=i.n(n),d={props:{defaultBinaryTime:{type:String,default:""}},data:function(){return{box_id:"table-time-selected",defaultTipColor:"rgb(32,45,61)",startTd:null,startTdIndex:null,endTd:null,endTdIndex:null,selectedCls:"time-selected",startX:null,startY:null,hour:null,tdState:0,weekData:["一","二","三","四","五","六","日"],timeSlot:[],timeWeekArr:[],displayHtml:"",timeBinary:[],weekArray:[{id:0,value:"星期一"},{id:1,value:"星期二"},{id:2,value:"星期三"},{id:3,value:"星期四"},{id:4,value:"星期五"},{id:5,value:"星期六"},{id:6,value:"星期日"}]}},created:function(){this.timeSlot=this.getTimeSlot()},mounted:function(){var t=this;this.binarySelected(),a()(".plug-timer-grid").on("mouseover",".showTip",function(e){var i=+a()(e.currentTarget).attr("weekindex"),r=+a()(e.currentTarget).attr("timeindex")-1;a()("#"+i+"_"+(r+1)).hasClass(t.selectedCls)||a()("#"+i+"_"+(r+1)).addClass("tdmouse-hover");var s=t.weekArray[i-1].value,n=null;l.a.forEach(t.timeSlot,function(e,a){if(r!==a);else{n=e.split(":");var l=t.calculationMinutes(n[0],n[1]),d=t.transFormMinuteToHour(+l-30);t.$layer.tips(s+" "+d+"-"+e,"#"+i+"_"+(r+1),{tips:[1,t.defaultTipColor],time:0})}})}),a()(".plug-timer-grid").on("mouseleave",".showTip",function(e){var i=+a()(e.currentTarget).attr("weekindex"),r=+a()(e.currentTarget).attr("timeindex")-1;a()("#"+i+"_"+(r+1)).removeClass("tdmouse-hover"),t.$layer.closeAll("tips")})},methods:{clearAll:function(){a()(".timeTableTbody").find("td").removeClass(this.selectedCls),this.refreshTable()},hoursColumnBar:function(t){if(this.hour=a()(t.currentTarget).attr("hourIndex"),this.hour>=0){var e=a()("#"+this.box_id+" table tbody tr").length;this.startX=2*+a()(t.currentTarget).attr("hourIndex")-1,this.startY=0,this.startTdIndex={x:this.startX,y:this.startY},this.endTd=a()(t.currentTarget);var i=2*+a()(t.currentTarget).attr("hourIndex")-2,r=e-1;this.endTdIndex={x:i,y:r},this.selectTdClick(this.startTdIndex,this.endTdIndex,this.selectedCls)}},weekColumnBar:function(t){if(a()(t.currentTarget).attr("weekIndex")>=0){var e=a()("#"+this.box_id+" table tbody tr td").length/(a()("#"+this.box_id+" table tbody tr").length-1);this.startX=0,this.startY=+a()(t.currentTarget).attr("weekIndex")-1,this.startTdIndex={x:this.startX,y:this.startY},this.endTd=a()(t.currentTarget);var i=a()(t.currentTarget).attr("weekIndex")-1,r=e-1;this.endTdIndex={x:r,y:i},this.selectTdClick(this.startTdIndex,this.endTdIndex,this.selectedCls)}},tdMouseDown:function(t,e){var i=this;this.startX=t-1,this.startY=e-1,this.startTdIndex={x:this.startX,y:this.startY},this.endTd=this.$refs[e+"_"+t];var r=t-1,s=e-1;this.endTdIndex={x:r,y:s},this.selectTD(this.startTdIndex,this.endTdIndex,this.selectedCls),this.startTd=this.$refs[e+"_"+t],this.startTdIndex={x:this.startX,y:this.startY},a()("#"+this.box_id+" table tbody tr td").mouseover(function(t){i.endTd=t.currentTarget;var e=a()(t.currentTarget).attr("timeIndex")-1,r=a()(t.currentTarget).attr("weekIndex")-1;i.endTdIndex={x:e,y:r},1!==t.which&&a()("#"+i.box_id+" table tbody tr td").unbind("mouseover"),i.selectTD(i.startTdIndex,i.endTdIndex,i.selectedCls)}),a()(".table-time-selected").unbind("mouseup").bind("mouseup",function(){i.refreshTable()})},getTimeSlot:function(){var t=[],e=new Date;e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0);var i=e.getHours(),r=e.getMinutes();return l.a.times(48,function(s){e.setMinutes(e.getMinutes()+30),i=e.getHours(),r=e.getMinutes(),47===s&&0===i&&(i=24),r=r.toString().padStart(2,"0"),i=i.toString().padStart(2,"0"),t[s]=i+":"+r}),t},selectTD:function(t,e,i){var r,s,n,l,d=this.getCoordinate(t,e);r=d[0],s=d[1],n=d[2],l=d[3];for(var o=n;o<=l;o++)for(var u=r;u<=s;u++){var c=a()("#"+this.box_id+" table tbody tr ").eq(o),h=a()("td",c).eq(u).attr("class");this.tdState=a()("td",c).eq(u).attr("tdState"),this.tdState||(-1!=h.indexOf(this.selectedCls)?a()("td",c).eq(u).removeClass(this.selectedCls):a()("td",c).eq(u).removeClass("tdmouse-hover").addClass(this.selectedCls),a()("td",c).eq(u).attr("tdState","1"))}this.changeTimeBinary(),this.getBinaryConvertDate()},getCoordinate:function(t,e){var i=null,r=null,s=null,a=null;return t.x<e.x?(i=t.x,r=e.x):(i=e.x,r=t.x),t.y<e.y?(s=t.y,a=e.y):(s=e.y,a=t.y),[i,r,s,a]},changeTimeBinary:function(){var t=this;this.timeBinary.length=0,a()("#"+this.box_id+" table tbody").find("td").each(function(e){a()(this).hasClass("time-selected")?t.timeBinary.push("1"):t.timeBinary.push("0")}),this.$emit("selectedBinaryTime",this.timeBinary.join(""))},getBinaryConvertDate:function(){var t=this,e="",i=[],r=[],s=[],a=[];e=this.timeBinary.join(""),l.a.times(7,function(i){var s=[],a=void 0;l.a.times(48,function(r){a=0===i?r:48*i+r,1==+e.charAt(a)&&(1==+e.charAt(a-1)&&1==+e.charAt(a-2)?0===r&&0==+e.charAt(a+1)?s[s.length]=t.timeSlot[r]+", ":0===r&&1==+e.charAt(a+1)?s[s.length]=t.timeSlot[r]:1===r&&0==+e.charAt(a-1)?s[s.length]=t.timeSlot[r]+", ":1===r&&1==+e.charAt(a-1)?s[s.length]="-"+t.timeSlot[r]+", ":s[s.length-1]="-"+t.timeSlot[r]+", ":1==+e.charAt(a-1)&&r>0?s[s.length]="-"+t.timeSlot[r]+", ":1!=+e.charAt(a+1)||47===r?s[s.length]=t.timeSlot[r]+", ":s[s.length]=t.timeSlot[r])}),r[i]=s}),this.displayHtml="",l.a.times(7,function(e){if(l.a.forEach(r[e],function(t,i){s[e]=s[e]?s[e]+r[e][i]:r[e][i]}),s[e]){s[e]=s[e].substring(0,s[e].length-2);var n=s[e].split(","),d=t.displayTimeSlot(n);i.push(d),a.push("<div>星期"+t.weekData[e]+"("+d+")</div>")}}),this.displayHtml=a.join(""),this.$emit("selectedTimeStr",i.join(";"))},displayTimeSlot:function(t){var e=this,i=[],r="";return l.a.forEach(t,function(t,s){r=l.a.trim(-1!==t.indexOf("-")?t.split("-")[1]:t);var a=e.transFormHalfHour(t),n=e.calculationMinutes(a[0],a[1]),d=e.transFormMinuteToHour(+n-30),o=r?d+"-"+r:d;i.push(o)}),i.join(",")},refreshTable:function(){a()("#"+this.box_id+" table tbody tr td").unbind("mouseover"),a()("#"+this.box_id+" table tbody tr td").attr("tdState",""),this.changeTimeBinary(),this.getBinaryConvertDate()},binarySelected:function(){var t=this;this.defaultBinaryTime&&(l.a.times(336,function(e){0!=+t.defaultBinaryTime.charAt(e)&&a()("#"+t.box_id+" table tbody tr td").eq(e).addClass(t.selectedCls)}),this.$nextTick(function(){this.refreshTable()}))},selectTdClick:function(t,e,i){var r,s,n,l=null,d=0,o=0,u=this.getCoordinate(t,e);r=u[0],s=u[1],n=u[2],l=7===(l=u[3])?l-1:l;for(var c=n;c<=l;c++)for(var h=r;h<=s;h++){var m=a()("#"+this.box_id+" table tbody tr ").eq(c),v=a()("td",m).eq(h).hasClass("time-selected");d=v?1:0,o=v?0:1}for(var f=n;f<=l;f++)for(var T=r;T<=s;T++){var p=a()("#"+this.box_id+" table tbody tr ").eq(f);1===d&&1===o?a()("td",p).eq(T).addClass(i):1===o?a()("td",p).eq(T).addClass(i):a()("td",p).eq(T).removeClass(i)}this.changeTimeBinary(),this.getBinaryConvertDate()},transFormHalfHour:function(t){var e=0;-1!=t.indexOf("-")?e=t.split("-")[0].split(":"):e=t.split(":");return e},calculationMinutes:function(t,e){return 60*+t+ +e},transFormMinuteToHour:function(t){var e=parseInt(+t/60);return t=+t%60,(e=e.toString().padStart(2,"0"))+":"+(t=t.toString().padStart(2,"0"))},getBinaryToTime:function(t){return this.getBinaryConvertDate(t)}}},o={render:function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",[i("div",{staticClass:"table-time-selected",attrs:{id:"table-time-selected"}},[i("table",{staticClass:"plug-timer-grid",attrs:{border:"0"}},[i("thead",[t._m(0),t._v(" "),i("tr",{staticStyle:{cursor:"pointer"}},[t._l(24,function(e){return[i("td",{key:e,attrs:{colspan:"2",hourIndex:e},on:{click:t.hoursColumnBar}},[t._v(t._s(e-1))])]})],2)]),t._v(" "),i("tbody",{staticClass:"timeTableTbody"},[t._l(t.weekArray,function(e){return[i("tr",{key:e.id+1},[i("th",{staticClass:"pull-left-info",attrs:{weekIndex:e.id+1},on:{click:t.weekColumnBar}},[t._v(t._s(e.value))]),t._v(" "),t._l(48,function(r){return[i("td",{key:r,ref:e.id+1+"_"+r,refInFor:!0,staticClass:"showTip",attrs:{id:e.id+1+"_"+r,value:e.id+1+"_"+r,weekIndex:e.id+1,timeIndex:r},on:{mousedown:function(i){t.tdMouseDown(r,e.id+1)}}})]})],2)]}),t._v(" "),i("tr",[i("td",{staticClass:"table-footer",attrs:{colspan:"49"}},[i("div",{staticClass:"duration-tipline"},[t._m(1),t._v(" "),i("span",{staticClass:"color-box color-blue"}),t._v(" "),i("span",[t._v("已选")]),t._v(" "),i("span",{staticClass:"weektip"},[t._v("可拖动鼠标选择时间段")]),t._v(" "),i("a",{staticClass:"emptied",on:{click:t.clearAll}},[t._v("清空")])])])])],2)])])])},staticRenderFns:[function(){var t=this.$createElement,e=this._self._c||t;return e("tr",[e("th",{staticClass:"pull-left-info",attrs:{rowspan:"2"}},[this._v("星期\\时间")]),this._v(" "),e("th",{attrs:{colspan:"24"}},[this._v("00:00 - 12:00")]),this._v(" "),e("th",{attrs:{colspan:"24"}},[this._v("12:00 - 24:00")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"left"},[e("span",{staticClass:"color-box"}),this._v(" "),e("span",[this._v("未选")])])}]};var u=i("VU/8")(d,o,!1,function(t){i("jMoT")},"data-v-1c139a6c",null).exports,c={data:function(){return{timeValue:""}},components:{timeTable:u},methods:{selectedBinaryTime:function(t){},selectedTimeStr:function(t){}}},h={render:function(){var t=this.$createElement,e=this._self._c||t;return e("div",[e("time-table",{attrs:{defaultBinaryTime:this.timeValue},on:{selectedTimeStr:this.selectedTimeStr,selectedBinaryTime:this.selectedBinaryTime}})],1)},staticRenderFns:[]};var m=i("VU/8")(c,h,!1,function(t){i("c4MY")},"data-v-2c848a89",null).exports,v=i("/ocq");r.a.use(v.a);var f=new v.a({routes:[{path:"/",name:"timeTable",component:u}]}),T=i("osWI"),p=i.n(T);r.a.config.productionTip=!1,r.a.prototype.$layer=p.a,new r.a({el:"#app",router:f,components:{App:m},template:"<App/>"})},c4MY:function(t,e){},jMoT:function(t,e){}},["NHnr"]); //# sourceMappingURL=app.8209e931b119fc3e3563.js.map