logistics_sy/public/mobile/assets/u-form-item.9efeed79.js

2 lines
24 KiB
JavaScript
Raw Normal View History

2023-11-08 15:13:08 +08:00
import{r as e,a as t,o as r,c as i,w as n,x as a,b as l,h as s,s as o,v as u,ap as f,I as d,k as c,l as p,t as h,E as g,y as m}from"./index.26a6cf84.js";import{_ as y}from"./u-icon.7191c6e8.js";import{E as b}from"./emitter.5b880544.js";import{_ as v}from"./plugin-vue_export-helper.21dcd24c.js";var S=v({name:"u-input",emits:["update:modelValue","input","change","blur","focus","click","touchstart"],mixins:[b],props:{value:{type:[String,Number],default:""},modelValue:{type:[String,Number],default:""},type:{type:String,default:"text"},inputAlign:{type:String,default:""},placeholder:{type:String,default:"请输入内容"},disabled:{type:Boolean,default:!1},maxlength:{type:[Number,String],default:140},placeholderStyle:{type:String,default:"color: #c0c4cc;"},confirmType:{type:String,default:"done"},customStyle:{type:Object,default:()=>({})},fixed:{type:Boolean,default:!1},focus:{type:Boolean,default:!1},passwordIcon:{type:Boolean,default:!0},border:{type:Boolean,default:!1},borderColor:{type:String,default:"#dcdfe6"},autoHeight:{type:Boolean,default:!0},selectOpen:{type:Boolean,default:!1},height:{type:[Number,String],default:""},clearable:{type:[Boolean,String]},cursorSpacing:{type:[Number,String],default:0},selectionStart:{type:[Number,String],default:-1},selectionEnd:{type:[Number,String],default:-1},trim:{type:Boolean,default:!0},showConfirmbar:{type:Boolean,default:!0},backgroundColor:{type:String},padding:{type:String}},data:()=>({defaultValue:"",inputHeight:70,textareaHeight:100,validateState:!1,focused:!1,showPassword:!1,lastValue:"",uForm:{inputAlign:"",clearable:""}}),watch:{valueCom(e,t){this.defaultValue=e,e!=t&&"select"==this.type&&this.handleInput({detail:{value:e}})}},computed:{valueCom(){return this.modelValue},inputAlignCom(){return this.inputAlign||this.uForm.inputAlign||"left"},clearableCom(){return"boolean"==typeof this.clearable?this.clearable:"boolean"!=typeof this.uForm.clearable||this.uForm.clearable},inputMaxlength(){return Number(this.maxlength)},getStyle(){let e={};return e.minHeight=this.height?this.height+"rpx":"textarea"==this.type?this.textareaHeight+"rpx":this.inputHeight+"rpx",e=Object.assign(e,this.customStyle),e},getCursorSpacing(){return Number(this.cursorSpacing)},uSelectionStart(){return String(this.selectionStart)},uSelectionEnd(){return String(this.selectionEnd)}},created(){this.defaultValue=this.valueCom},mounted(){let e=this.$u.$parent.call(this,"u-form");e&&Object.keys(this.uForm).map((t=>{this.uForm[t]=e[t]}))},methods:{handleInput(e){let t=e.detail.value;this.trim&&(t=this.$u.trim(t)),this.$emit("input",t),this.$emit("update:modelValue",t),this.defaultValue=t,setTimeout((()=>{this.dispatch("u-form-item","onFieldChange",t)}),40)},handleBlur(e){setTimeout((()=>{this.focused=!1}),100),this.$emit("blur",e.detail.value),setTimeout((()=>{this.dispatch("u-form-item","onFieldBlur",e.detail.value)}),40)},onFormItemError(e){this.validateState=e},onFocus(e){this.focused=!0,this.$emit("focus")},onConfirm(e){this.$emit("confirm",e.detail.value)},onClear(e){this.$emit("input",""),this.$emit("update:modelValue","")},inputClick(){this.$emit("click")}}},[["render",function(p,h,g,m,b,v){const S=f,_=d,w=e(t("u-icon"),y),x=c;return r(),i(x,{class:o(["u-input",{"u-input--border":g.border,"u-input--error":b.validateState}]),style:a({padding:g.padding?g.padding:`0 ${g.border?20:0}rpx`,borderColor:g.borderColor,textAlign:v.inputAlignCom,backgroundColor:g.backgroundColor}),onClick:u(v.inputClick,["stop"])},{default:n((()=>["textarea"==g.type?(r(),i(S,{key:0,class:"u-input__input u-input__textarea",style:a([v.getStyle]),value:b.defaultValue,placeholder:g.placeholder,placeholderStyle:g.placeholderStyle,disabled:g.disabled,maxlength:v.inputMaxlength,fixed:g.fixed,focus:g.focus,autoHeight:g.autoHeight,"selection-end":v.uSelectionEnd,"selection-start":v.uSelectionStart,"cursor-spacing":v.getCursorSpacing,onInput:v.handleInput,onBlur:v.handleBlur,onFocus:v.onFocus,onConfirm:v.onConfirm},null,8,["style","value","placeholder","placeholderStyle","disabled","maxlength","fixed","focus","autoHeight","selection-end","se