UNPKG

bangpicker

Version:

picker 选择器,最多3列

2 lines 15.8 kB
(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["BangPicker"]=e():t["BangPicker"]=e()})("undefined"!==typeof self?self:this,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="fb15")}({"0d58":function(t,e,n){var r=n("ce10"),o=n("e11e");t.exports=Object.keys||function(t){return r(t,o)}},"11e9":function(t,e,n){var r=n("52a7"),o=n("4630"),i=n("6821"),c=n("6a99"),a=n("69a8"),s=n("c69a"),u=Object.getOwnPropertyDescriptor;e.f=n("9e1e")?u:function(t,e){if(t=i(t),e=c(e,!0),s)try{return u(t,e)}catch(n){}if(a(t,e))return o(!r.f.call(t,e),t[e])}},1495:function(t,e,n){var r=n("86cc"),o=n("cb7c"),i=n("0d58");t.exports=n("9e1e")?Object.defineProperties:function(t,e){o(t);var n,c=i(e),a=c.length,s=0;while(a>s)r.f(t,n=c[s++],e[n]);return t}},2010:function(t,e,n){},"230e":function(t,e,n){var r=n("d3f4"),o=n("7726").document,i=r(o)&&r(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},"2aba":function(t,e,n){var r=n("7726"),o=n("32e9"),i=n("69a8"),c=n("ca5a")("src"),a="toString",s=Function[a],u=(""+s).split(a);n("8378").inspectSource=function(t){return s.call(t)},(t.exports=function(t,e,n,a){var s="function"==typeof n;s&&(i(n,"name")||o(n,"name",e)),t[e]!==n&&(s&&(i(n,c)||o(n,c,t[e]?""+t[e]:u.join(String(e)))),t===r?t[e]=n:a?t[e]?t[e]=n:o(t,e,n):(delete t[e],o(t,e,n)))})(Function.prototype,a,function(){return"function"==typeof this&&this[c]||s.call(this)})},"2aeb":function(t,e,n){var r=n("cb7c"),o=n("1495"),i=n("e11e"),c=n("613b")("IE_PROTO"),a=function(){},s="prototype",u=function(){var t,e=n("230e")("iframe"),r=i.length,o="<",c=">";e.style.display="none",n("fab2").appendChild(e),e.src="javascript:",t=e.contentWindow.document,t.open(),t.write(o+"script"+c+"document.F=Object"+o+"/script"+c),t.close(),u=t.F;while(r--)delete u[s][i[r]];return u()};t.exports=Object.create||function(t,e){var n;return null!==t?(a[s]=r(t),n=new a,a[s]=null,n[c]=t):n=u(),void 0===e?n:o(n,e)}},"2d00":function(t,e){t.exports=!1},"2d95":function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},"32e9":function(t,e,n){var r=n("86cc"),o=n("4630");t.exports=n("9e1e")?function(t,e,n){return r.f(t,e,o(1,n))}:function(t,e,n){return t[e]=n,t}},4588:function(t,e){var n=Math.ceil,r=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?r:n)(t)}},4630:function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},"52a7":function(t,e){e.f={}.propertyIsEnumerable},5537:function(t,e,n){var r=n("8378"),o=n("7726"),i="__core-js_shared__",c=o[i]||(o[i]={});(t.exports=function(t,e){return c[t]||(c[t]=void 0!==e?e:{})})("versions",[]).push({version:r.version,mode:n("2d00")?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},"5ca1":function(t,e,n){var r=n("7726"),o=n("8378"),i=n("32e9"),c=n("2aba"),a=n("9b43"),s="prototype",u=function(t,e,n){var f,l,p,h,d=t&u.F,v=t&u.G,b=t&u.S,y=t&u.P,m=t&u.B,g=v?r:b?r[e]||(r[e]={}):(r[e]||{})[s],x=v?o:o[e]||(o[e]={}),_=x[s]||(x[s]={});for(f in v&&(n=e),n)l=!d&&g&&void 0!==g[f],p=(l?g:n)[f],h=m&&l?a(p,r):y&&"function"==typeof p?a(Function.call,p):p,g&&c(g,f,p,t&u.U),x[f]!=p&&i(x,f,h),y&&_[f]!=p&&(_[f]=p)};r.core=o,u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,t.exports=u},"5dbc":function(t,e,n){var r=n("d3f4"),o=n("8b97").set;t.exports=function(t,e,n){var i,c=e.constructor;return c!==n&&"function"==typeof c&&(i=c.prototype)!==n.prototype&&r(i)&&o&&o(t,i),t}},"613b":function(t,e,n){var r=n("5537")("keys"),o=n("ca5a");t.exports=function(t){return r[t]||(r[t]=o(t))}},"626a":function(t,e,n){var r=n("2d95");t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==r(t)?t.split(""):Object(t)}},6821:function(t,e,n){var r=n("626a"),o=n("be13");t.exports=function(t){return r(o(t))}},"69a8":function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},"6a99":function(t,e,n){var r=n("d3f4");t.exports=function(t,e){if(!r(t))return t;var n,o;if(e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;if("function"==typeof(n=t.valueOf)&&!r(o=n.call(t)))return o;if(!e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},"70bb":function(t,e,n){},"762f":function(t,e,n){"use strict";var r=n("70bb"),o=n.n(r);o.a},7726:function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},"77f1":function(t,e,n){var r=n("4588"),o=Math.max,i=Math.min;t.exports=function(t,e){return t=r(t),t<0?o(t+e,0):i(t,e)}},"79e5":function(t,e){t.exports=function(t){try{return!!t()}catch(e){return!0}}},"7f7f":function(t,e,n){var r=n("86cc").f,o=Function.prototype,i=/^\s*function ([^ (]*)/,c="name";c in o||n("9e1e")&&r(o,c,{configurable:!0,get:function(){try{return(""+this).match(i)[1]}catch(t){return""}}})},8378:function(t,e){var n=t.exports={version:"2.5.7"};"number"==typeof __e&&(__e=n)},"86cc":function(t,e,n){var r=n("cb7c"),o=n("c69a"),i=n("6a99"),c=Object.defineProperty;e.f=n("9e1e")?Object.defineProperty:function(t,e,n){if(r(t),e=i(e,!0),r(n),o)try{return c(t,e,n)}catch(a){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},"8b97":function(t,e,n){var r=n("d3f4"),o=n("cb7c"),i=function(t,e){if(o(t),!r(e)&&null!==e)throw TypeError(e+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,e,r){try{r=n("9b43")(Function.call,n("11e9").f(Object.prototype,"__proto__").set,2),r(t,[]),e=!(t instanceof Array)}catch(o){e=!0}return function(t,n){return i(t,n),e?t.__proto__=n:r(t,n),t}}({},!1):void 0),check:i}},9093:function(t,e,n){var r=n("ce10"),o=n("e11e").concat("length","prototype");e.f=Object.getOwnPropertyNames||function(t){return r(t,o)}},"95e2":function(t,e,n){"use strict";var r=n("2010"),o=n.n(r);o.a},"9b43":function(t,e,n){var r=n("d8e8");t.exports=function(t,e,n){if(r(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}}},"9def":function(t,e,n){var r=n("4588"),o=Math.min;t.exports=function(t){return t>0?o(r(t),9007199254740991):0}},"9e1e":function(t,e,n){t.exports=!n("79e5")(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},aa77:function(t,e,n){var r=n("5ca1"),o=n("be13"),i=n("79e5"),c=n("fdef"),a="["+c+"]",s="​…",u=RegExp("^"+a+a+"*"),f=RegExp(a+a+"*$"),l=function(t,e,n){var o={},a=i(function(){return!!c[t]()||s[t]()!=s}),u=o[t]=a?e(p):c[t];n&&(o[n]=u),r(r.P+r.F*a,"String",o)},p=l.trim=function(t,e){return t=String(o(t)),1&e&&(t=t.replace(u,"")),2&e&&(t=t.replace(f,"")),t};t.exports=l},be13:function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},c366:function(t,e,n){var r=n("6821"),o=n("9def"),i=n("77f1");t.exports=function(t){return function(e,n,c){var a,s=r(e),u=o(s.length),f=i(c,u);if(t&&n!=n){while(u>f)if(a=s[f++],a!=a)return!0}else for(;u>f;f++)if((t||f in s)&&s[f]===n)return t||f||0;return!t&&-1}}},c5f6:function(t,e,n){"use strict";var r=n("7726"),o=n("69a8"),i=n("2d95"),c=n("5dbc"),a=n("6a99"),s=n("79e5"),u=n("9093").f,f=n("11e9").f,l=n("86cc").f,p=n("aa77").trim,h="Number",d=r[h],v=d,b=d.prototype,y=i(n("2aeb")(b))==h,m="trim"in String.prototype,g=function(t){var e=a(t,!1);if("string"==typeof e&&e.length>2){e=m?e.trim():p(e,3);var n,r,o,i=e.charCodeAt(0);if(43===i||45===i){if(n=e.charCodeAt(2),88===n||120===n)return NaN}else if(48===i){switch(e.charCodeAt(1)){case 66:case 98:r=2,o=49;break;case 79:case 111:r=8,o=55;break;default:return+e}for(var c,s=e.slice(2),u=0,f=s.length;u<f;u++)if(c=s.charCodeAt(u),c<48||c>o)return NaN;return parseInt(s,r)}}return+e};if(!d(" 0o1")||!d("0b1")||d("+0x1")){d=function(t){var e=arguments.length<1?0:t,n=this;return n instanceof d&&(y?s(function(){b.valueOf.call(n)}):i(n)!=h)?c(new v(g(e)),n,d):g(e)};for(var x,_=n("9e1e")?u(v):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),w=0;_.length>w;w++)o(v,x=_[w])&&!o(d,x)&&l(d,x,f(v,x));d.prototype=b,b.constructor=d,n("2aba")(r,h,d)}},c69a:function(t,e,n){t.exports=!n("9e1e")&&!n("79e5")(function(){return 7!=Object.defineProperty(n("230e")("div"),"a",{get:function(){return 7}}).a})},ca5a:function(t,e){var n=0,r=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++n+r).toString(36))}},cb7c:function(t,e,n){var r=n("d3f4");t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},ce10:function(t,e,n){var r=n("69a8"),o=n("6821"),i=n("c366")(!1),c=n("613b")("IE_PROTO");t.exports=function(t,e){var n,a=o(t),s=0,u=[];for(n in a)n!=c&&r(a,n)&&u.push(n);while(e.length>s)r(a,n=e[s++])&&(~i(u,n)||u.push(n));return u}},d3f4:function(t,e){t.exports=function(t){return"object"===typeof t?null!==t:"function"===typeof t}},d8e8:function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},e11e:function(t,e){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},fab2:function(t,e,n){var r=n("7726").document;t.exports=r&&r.documentElement},fb15:function(t,e,n){"use strict";var r;(n.r(e),"undefined"!==typeof window)&&((r=window.document.currentScript)&&(r=r.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))&&(n.p=r[1]));n("7f7f");var o=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"bang-picker",class:t.showDate?"active":""},[n("div",{staticClass:"picker-box"},[n("div",{staticClass:"tit-box"},[n("p",{staticClass:"btn cancel",on:{click:t.hideBox}},[t._v("取消")]),n("p",{staticClass:"btn",on:{click:t.sure}},[t._v("确定")])]),n("div",{ref:"box",staticClass:"list-box",on:{touchstart:t.stopTouch}},t._l(t.numLine,function(e){return n("child-slot",{key:e,ref:"box"+(e-1),refInFor:!0,attrs:{slotsKey:e-1},on:{eventPicker:t.changePicker}})}))])])},i=[],c=(n("c5f6"),function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{ref:"box",staticClass:"line",on:{mousedown:t.doTouchstart,touchstart:t.doTouchstart,mouseup:t.doTouchend,touchend:t.doTouchend}},[n("ul",{style:{transform:"translate3d(0, "+t.dance+"px, 0)"}},[n("li"),n("li"),t._l(t.listArr,function(e,r){return n("li",{key:r,class:e.active?"active":""},[t._v("\n "+t._s(e.name)+"\n ")])}),n("li"),n("li")],2)])}),a=[],s={name:"child-slot",data:function(){return{direction:"up",startx:Number,starty:Number,yStart:Number,yEnd:Number,listLiH:0,dance:0,maxDance:Number,listArr:[],mobile:!0}},props:{slotsKey:Number},created:function(){"ontouchstart"in window?this.mobile=!0:this.mobile=!1},methods:{getAngle:function(t,e){return 180*Math.atan2(e,t)/Math.PI},getDirection:function(t,e,n,r){var o=n-t,i=r-e,c=0;if(Math.abs(o)<2&&Math.abs(i)<2)return c;var a=this.getAngle(o,i);return a>=-135&&a<=-45?c=1:a>45&&a<135?c=2:a>=135&&a<=180||a>=-180&&a<-135?c=3:a>=-45&&a<=45&&(c=4),c},doTouchstart:function(t){this.mobile?(this.startx=t.touches[0].pageX,this.starty=t.touches[0].pageY,this.yStart=t.touches[0].pageY):(this.startx=t.pageX,this.starty=t.pageY,this.yStart=t.pageY)},doTouchend:function(t){var e,n;this.mobile?(e=t.changedTouches[0].pageX,n=t.changedTouches[0].pageY,this.yEnd=t.changedTouches[0].pageY):(e=t.pageX,n=t.pageY,this.yEnd=t.pageY);var r=this.getDirection(this.startx,this.starty,e,n);switch(r){case 0:break;case 1:this.doMove("up");break;case 2:this.doMove("down");break;case 3:break;case 4:break;default:}},doMove:function(t){var e=this.yEnd,n=this.yStart,r=+n-+e,o=Math.ceil(Math.abs(r)/this.listLiH);if("up"==t){var i=this.listLiH*o+Math.abs(this.dance);i>this.maxDance?this.dance=-this.maxDance:this.dance=-i}else if("down"==t){var c=Math.abs(this.dance)-this.listLiH*o;this.dance=c<0?0:-c}var a=Math.abs(this.dance)/this.listLiH;this.setVal(a)},setVal:function(t){var e=this.listArr;e.map(function(t){t.active&&delete t.active}),e[t]["active"]=!0,this.listArr=e,this.$emit("eventPicker",{chooseVal:e[t],index:this.slotsKey})},setList:function(t,e){this.listArr=t,this.setVal(e),this.listLiH=this.$refs.box.offsetHeight/5,this.maxDance=(this.listArr.length-1)*this.listLiH,this.dance=-this.listLiH*e}}},u=s;n("95e2");function f(t,e,n,r,o,i,c,a){var s,u="function"===typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=n,u._compiled=!0),r&&(u.functional=!0),i&&(u._scopeId="data-v-"+i),c?(s=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(c)},u._ssrRegister=s):o&&(s=a?function(){o.call(this,this.$root.$options.shadowRoot)}:o),s)if(u.functional){u._injectStyles=s;var f=u.render;u.render=function(t,e){return s.call(e),f(t,e)}}else{var l=u.beforeCreate;u.beforeCreate=l?[].concat(l,s):[s]}return{exports:t,options:u}}var l=f(u,c,a,!1,null,"611ddbfc",null);l.options.__file="childSlot.vue";var p=l.exports,h={name:"bang-picker",components:{ChildSlot:p},data:function(){return{showDate:!1,chooseVal:{}}},props:{numLine:Number,sumData:Array},mounted:function(){},methods:{showBox:function(){this.$refs.box.style.height="200px",this.showDate=!0,this.chooseVal={}},hideBox:function(){var t=this;this.$refs.box.style.height="0",setTimeout(function(){t.showDate=!1},300)},stopTouch:function(t){t.preventDefault()},changePicker:function(t){t.chooseVal.child&&Object.getOwnPropertyNames(this.chooseVal).length>this.numLine&&this.$refs["box".concat(t.index+1)][0].setList(t.chooseVal.child,0),this.chooseVal[t.index]={code:t.chooseVal.code,name:t.chooseVal.name}},setPicker:function(t){for(var e=0;e<this.sumData.length;e++)if(this.sumData[e].code==t[0].code){this.$refs["box".concat(0)][0].setList(this.sumData,e);var n=this.sumData[e].child;if(n.length>0)for(var r=0;r<n.length;r++)if(n[r].code==t[1].code){this.$refs["box".concat(1)][0].setList(n,r);var o=n[r].child;if(o&&o.length>0)for(var i=0;i<o.length;i++)if(o[i].code==t[2].code){this.$refs["box".concat(2)][0].setList(o,i);break}break}break}},sure:function(){this.hideBox(),this.$emit("eventPicker",this.chooseVal)}}},d=h,v=(n("762f"),f(d,o,i,!1,null,"17a0852a",null));v.options.__file="picker.vue";var b=v.exports,y=function(t){t.component(b.name,b)};"undefined"!==typeof window&&window.Vue&&y(window.Vue);var m=y;e["default"]=m},fdef:function(t,e){t.exports="\t\n\v\f\r   ᠎              \u2028\u2029\ufeff"}})}); //# sourceMappingURL=BangPicker.umd.min.js.map