| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- <template>
- <div class="my-inputBox">
- <div class="line"></div>
- <div class="my-title">
- <slot class="title">
- <span>{{title}}</span>
- </slot>
- <slot name="icon"></slot>
- </div>
- <div
- :class="['my-input',arrowsRight?'isLink':'']">
- <slot name="content">
- <!-- <textarea
- auto-height
- v-if="type == 'textarea'"
- class="text-line text-textarea"
- :disabled="disabled"
- ref="input"
- :type="type"
- v-model="currentValue"
- @blur="onBlur"
- @input="onChange"
- :isFocus="true"
- :placeholder="placeholder">
- </textarea> -->
- <appTextarea
- auto-height
- v-if="type == 'textarea'"
- class="text-line text-textarea"
- :disabled="disabled"
- ref="input"
- :type="type"
- v-model="currentValue"
- @blur="onBlur"
- @input="onChange"
- :focus="isFocus"
- :placeholder="placeholder"
- ></appTextarea>
- <input
- v-else
- class="text-line"
- :disabled="disabled"
- ref="input"
- :type="type"
- v-model="currentValue"
- @blur="onBlur"
- @input="onChange"
- :focus="isFocus"
- :placeholder="placeholder">
- </slot>
- <!-- <i class="icon-butongguo" v-show="isClear&¤tValue !== ''" @click="clear"></i> -->
- </div>
- <div class="my-left">
- <slot name="inputRight"></slot>
- </div>
- </div>
- </template>
- <script>
- import appTextarea from './app-textarea'
- export default {
- name: 'app_input_all',
- components: {
- appTextarea
- },
- data() {
- return {
- currentValue: ''
- }
- },
- props: {
- value: {
- type: [String, Number]
- },
- title: {
- type: String
- },
- type: {
- type: String,
- default: 'text'
- },
- placeholder: {
- type: String
- },
- isClear: {
- type: Boolean,
- default: true
- },
- isFocus: {
- type: Boolean,
- default: false
- },
- disabled: {
- type: Boolean,
- default: false
- },
- arrowsRight: {
- type: Boolean,
- default: false
- }
- },
- created() {
- this.currentValue = (this.value === undefined || this.value === null) ? '' : this.value
- },
- mounted() {
- if (this.isFocus) {
- this.focus()
- }
- },
- methods: {
- clear() {
- this.currentValue = ''
- this.focus()
- },
- focus() {
- this.$refs.input.focus()
- },
- blur() {
- this.$refs.input.blur()
- },
- onBlur($event) {
- this.$emit('on-blur', this.currentValue, $event)
- },
- onChange(event) {
- let val = null
- if (this.type == 'text') {
- val = event.target.value
- } else {
- val = event
- }
- this.$emit('on-change', val)
- }
- },
- watch: {
- value(val) {
- this.currentValue = val
- },
- currentValue(val) {
- this.$emit('input', val)
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .my-inputBox{
- position: relative;
- display: flex;
- align-items: center;
- justify-content: center;
- box-sizing: content-box;
- padding-bottom: 15upx;
- & .line{
- position: absolute;
- width: 100%;
- height: 1upx;
- left: 0;
- bottom: 0;
- border-bottom: 1upx solid #ebedf0;
- }
- .my-input{
- position: relative;
- flex: 1;
- box-sizing: content-box;
- & .text-textarea {
- min-height: 150upx;
- display: inline-block;
- width: 100%;
- padding: 20upx 20upx 20upx 10upx;
- box-sizing: border-box;
- }
- & input{
- min-height: 88upx;
- padding-left: 10upx;
- padding-right: 50upx;
- }
- &.isLink::after{
- content: "";
- display: inline-block;
- width: 15upx;
- height: 15upx;
- border-width:2upx 2upx 0 0;
- border-color:#C8C8CD;
- border-style:solid;
- position: absolute;
- top: 50%;
- right: 30upx;
- transform: translate(0,-50%) matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
- }
- }
- }
- input,textarea{
- -webkit-appearance:none;
- outline:0;
- background-color:transparent;
- border:0;
- font-size: 28upx;
- font-weight: normal;
- font-stretch: normal;
- letter-spacing: 0upx;
- color: #4d4d4d;
- display: block;
- }
- .icon-butongguo{
- color: #cccccc;
- font-size: 28upx;
- position: absolute;
- padding: 20upx 10upx 20upx 20upx;
- right: 0;
- top: 50%;
- transform: translate(0,-50%);
- }
- .my-title {
- color: #666;
- font-size: 28upx;
- width: 180upx;
- }
- </style>
|