crm_second_opening_mini/pagesA/punchclock/clockrules/addClocktime.js

1 line
6.5 KiB
JavaScript

require('../../common/vendor.js');(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pagesA/punchclock/clockrules/addClocktime"],{"19b3":function(t,e,n){"use strict";(function(t,e){var i=n("4ea4");n("8886");i(n("66fd"));var s=i(n("6bdf"));t.__webpack_require_UNI_MP_PLUGIN__=n,e(s.default)}).call(this,n("bc2e")["default"],n("543d")["createPage"])},"47fe":function(t,e,n){"use strict";var i=n("5c8f"),s=n.n(i);s.a},"555b":function(t,e,n){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=n("0c59"),s=n("dc92"),r={data:function(){return{noClick:!0,BASE_IMG_URL:i.BASE_IMG_URL,arr:[{name:"一",isSet:!1,select:!0,en:"monday"},{name:"二",isSet:!1,select:!0,en:"tuesday"},{name:"三",isSet:!1,select:!0,en:"wednesday"},{name:"四",isSet:!1,select:!0,en:"thursday"},{name:"五",isSet:!1,select:!0,en:"friday"},{name:"六",isSet:!1,select:!1,en:"saturday"},{name:"日",isSet:!1,select:!1,en:"weekday"}],timeArr:[{start_time:"09:00",ustart_time:"07:59",uend_time:"08:59",start_next:0,start_status:0,end_time:"17:00",dstart_time:"17:01",dend_time:"17:59",end_next:0,end_status:0}],isProblem:!1,problemTit:"",number:null}},onLoad:function(e){e.number&&(this.number=e.number),t.removeStorageSync("timeArr"),this.getData()},onShow:function(){t.getStorageSync("timeArr")&&(this.timeArr=t.getStorageSync("timeArr"))},methods:{getDetail:function(){var t=this;(0,s.netTimeSlotDetail)({number:this.number}).then((function(e){e=e.data,t.timeArr=e.time;var n=t.arr;n.forEach((function(t){1==e[t.en]&&t.isSet&&(t.isSet=!1,t.select=!0)})),t.arr=n}))},getData:function(){var t=this;(0,s.netisSetTimeslot)().then((function(e){e=e.data;var n=t.arr,i=function(t){n.forEach((function(n,i){n.en==t&&(n.isSet=1==e[t]),n.select=!1}))};for(var s in e)i(s);t.arr=n,t.number&&t.getDetail()}))},selectWeek:function(t){var e=this.arr[t];e.isSet||(e.select=!e.select,this.$set(this.arr,t,e))},toAddClock:function(){var t,e,n,i,s=this.timeArr[this.timeArr.length-1],r=Number(s.end_time.substring(0,2)),a=null,o=null,l=0,c=0;23==r?(a="00",o="01",l=1,c=1,t="22:59",e="01:59",n="01:01",i="01:59"):a<23&&0==s.end_next?(a=this.handleTime(r+1),o=this.handleTime(r+2),t=this.handleTime(r-1)+":59",e=this.handleTime(r)+":59",n=this.handleTime(r+2)+":01",i=this.handleTime(r+2)+":59"):a<23&&1==s.end_next&&(a=this.handleTime(r+1),o=this.handleTime(r+2),l=1,c=1,t=this.handleTime(r-1)+":59",e=this.handleTime(r)+":59",n=this.handleTime(r+2)+":01",i=this.handleTime(r+2)+":59");var m={start_time:a+":00",start_next:l,ustart_time:t,uend_time:e,end_time:o+":00",dstart_time:n,dend_time:i,end_next:c,start_status:0,end_status:0};this.timeArr.push(m)},delClock:function(t){this.timeArr.splice(t,1)},changeGoto:function(e,n){var i=e.detail.value,s=this.timeArr[n];if(s.start_time=i,1!=s.end_next){var r=s.start_time.split(":"),a=s.end_time.split(":"),o=new Date;if(o.setHours(r[0],r[1])>o.setHours(a[0],a[1])?(t.showToast({title:"上班时间应该早于下班时间",icon:"none"}),this.isProblem=!0,this.problemTit="上班时间应该早于下班时间"):(this.isProblem=!1,this.problemTit=""),0!=n){var l=this.timeArr[n-1];i<l.end_time&&(s.start_next=1,s.end_next=1)}}else if(1==s.end_next&&n>0){var c=this.timeArr[n-1],m=s.start_time.split(":"),u=c.end_time.split(":"),h=new Date;h.setHours(m[0],m[1])<h.setHours(u[0],u[1])?(t.showToast({title:"上班时间应该大于上一段的下班时间",icon:"none"}),this.isProblem=!0,this.problemTit="上班时间应该大于上一段的下班时间"):(s.start_next=0,this.isProblem=!0,this.problemTit="")}this.$set(this.timeArr,n,s)},changeGoOff:function(e,n){var i=this,s=e.detail.value,r=this.timeArr[n];r.end_time=s;var a=r.start_time.split(":"),o=r.end_time.split(":"),l=new Date;if(0==r.start_next&&0==r.end_next&&l.setHours(a[0],a[1])>l.setHours(o[0],o[1])&&(r.end_next=1),(1==r.start_next&&1==r.end_next||0==r.start_next&&0==r.end_next)&&(l.setHours(a[0],a[1])>l.setHours(o[0],o[1])?(t.showToast({title:"上班时间应该早于下班时间",icon:"none"}),this.isProblem=!0,this.problemTit="上班时间应该早于下班时间"):(this.isProblem=!1,this.problemTit="")),1==r.end_next&&0==this.timeArr[0].start_next){var c=this.timeArr[0].start_time,m=s;this.handleSameday(c,m)||t.showModal({title:"提示",content:"最早上班时间与最晚下班时间跨度不能超过24小时",showCancel:!1,complete:function(t){t.confirm&&(i.isProblem=!0,i.problemTit="最早上班时间与最晚下班时间跨度不能超过24小时")}})}this.$set(this.timeArr,n,r)},handleSameday:function(t,e){if(!t||!e)return"";var n=t.split(":"),i=parseInt(60*n[0])+parseInt(n[1]),s=e.split(":"),r=parseInt(60*s[0])+parseInt(s[1]),a=1440-i+r;return!(a>1440)},toSetPeriod:function(){t.setStorageSync("timeArr",this.timeArr),t.navigateTo({url:"/pagesA/punchclock/clockrules/clockPeriod"})},toSave:function(){var e={},n=0;if(this.arr.forEach((function(t){t.isSet?(n++,e[t.en]=0):e[t.en]=t.select?1:0})),n>=7)t.showToast({title:"周一至周日已全部设置",icon:"none"});else{var i=0;this.arr.forEach((function(t){t.select&&i++})),i<=0?t.showToast({title:"请选择需要设置的星期",icon:"none"}):(e.time=this.timeArr,console.log(e),this.number?(e.number=this.number,(0,s.netEditTimeSlot)(e).then((function(e){t.showToast({title:e.msg,icon:"none"}),setTimeout((function(){t.navigateBack({delta:1})}),2e3)}))):(0,s.netAddTimeSlot)(e).then((function(e){t.showToast({title:e.msg,icon:"none"}),setTimeout((function(){t.navigateBack({delta:1})}),2e3)})))}},sureDel:function(){var e=this;t.showModal({title:"提示",content:"请确认是否删除?",complete:function(n){n.confirm&&(0,s.netDelTimeSlot)({number:e.number}).then((function(e){t.showToast({title:e.msg,icon:"none"}),setTimeout((function(){t.navigateBack({delta:1})}),2e3)}))}})}}};e.default=r}).call(this,n("543d")["default"])},"5c8f":function(t,e,n){},"60e2":function(t,e,n){"use strict";n.r(e);var i=n("555b"),s=n.n(i);for(var r in i)["default"].indexOf(r)<0&&function(t){n.d(e,t,(function(){return i[t]}))}(r);e["default"]=s.a},"6bdf":function(t,e,n){"use strict";n.r(e);var i=n("821d"),s=n("60e2");for(var r in s)["default"].indexOf(r)<0&&function(t){n.d(e,t,(function(){return s[t]}))}(r);n("47fe");var a=n("f0c5"),o=Object(a["a"])(s["default"],i["b"],i["c"],!1,null,"669e79ec",null,!1,i["a"],void 0);e["default"]=o.exports},"821d":function(t,e,n){"use strict";n.d(e,"b",(function(){return i})),n.d(e,"c",(function(){return s})),n.d(e,"a",(function(){}));var i=function(){var t=this.$createElement,e=(this._self._c,this.timeArr.length),n=this.timeArr.length,i=this.timeArr.length;this.$mp.data=Object.assign({},{$root:{g0:e,g1:n,g2:i}})},s=[]}},[["19b3","common/runtime","common/vendor"]]]);