shu-c-view
Version:
rollup 打包vue组件库框架
7 lines (6 loc) • 2.99 kB
JavaScript
/*!
* shu-c-view v1.2.37
* (c) 2022-09-22
* @license MIT
*/
;Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash/toString"),t=require("lodash/isNil");function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var n=r(e),o=r(t);function i(e,t,r,n,o,i,s,u,a,c){"boolean"!=typeof s&&(a=u,u=s,s=!1);const l="function"==typeof r?r.options:r;let p;if(e&&e.render&&(l.render=e.render,l.staticRenderFns=e.staticRenderFns,l._compiled=!0,o&&(l.functional=!0)),n&&(l._scopeId=n),i?(p=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__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(i)},l._ssrRegister=p):t&&(p=s?function(e){t.call(this,c(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,u(e))}),p)if(l.functional){const e=l.render;l.render=function(t,r){return p.call(r),e(t,r)}}else{const e=l.beforeCreate;l.beforeCreate=e?[].concat(e,p):[p]}return r}const s={name:"BasePriceInput",props:{label:{type:String,default:""},prop:{type:String,default:""},placeholder:{type:String,default:"请输入"},width:{type:Number,default:140},amountValue:{type:[String,Number],default:""},rules:{type:Object,default:()=>{}}},data:()=>({curDeceivedAmount:"",showFormatPrice:!1}),computed:{formateDeceivedAmount(){if(""!==this.curDeceivedAmount&&null!==this.curDeceivedAmount){const e=this.curDeceivedAmount.split(".")[0],t=this.curDeceivedAmount.split(".")[1]?`.${this.curDeceivedAmount.split(".")[1]}`:"";return`${e.toString().replace(/(?=(?!^)(\d{3})+$)/g,",")}${t}`}return""}},created(){o(this.amountValue)||this.blurInput()},methods:{focusInput(){this.showFormatPrice=!1,this.$nextTick(this.$refs.input.focus)},blurInput(){const e=n(this.amountValue);if(""!==e){const t=Number(e.split(".")[0]),r=e.split(".")[1]?`.${e.split(".")[1]}`:"",n=isNaN(`${t}${r}`)?e:`${t}${r}`;if("object"!=typeof this.rules[this.prop][0].pattern)throw new Error(`请确保 rules[${this.prop}][0].pattern 为正则表达式`);this.showFormatPrice=this.rules[this.prop][0].pattern.test(n),this.curDeceivedAmount=n}},onInput(e){this.$emit("update:amountValue",e)}}};var u=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("el-form-item",{attrs:{label:e.label,prop:e.prop}},[r("el-input",{directives:[{name:"show",rawName:"v-show",value:!e.showFormatPrice,expression:"!showFormatPrice"}],ref:"input",style:"width: "+e.width+"px",attrs:{value:e.amountValue,placeholder:e.placeholder},on:{input:e.onInput,blur:e.blurInput}}),e._v(" "),r("el-input",{directives:[{name:"show",rawName:"v-show",value:e.showFormatPrice,expression:"showFormatPrice"}],style:"width: "+e.width+"px",attrs:{value:e.formateDeceivedAmount},on:{focus:e.focusInput}})],1)};u._withStripped=!0;const a=i({render:u,staticRenderFns:[]},undefined,s,undefined,false,undefined,!1,void 0,void 0,void 0);exports.BasePriceInput=a;