| | |
| | | @blur="onChange" @confirm="onConfirm" @click="onClick" :disabled="data.disabled" :maxlength="-1"></input> |
| | | <input v-else class="oi-input" :class="data.disabled?'input-disabled':''" |
| | | :style="{'padding-left':data.setting.prefix?0 : '8rpx','right':data.setting.suffix?0 : '8rpx'}" |
| | | v-model="data.value" :focus="focus" :placeholder="data.placeholder" @blur="onChange" @confirm="onConfirm" |
| | | v-model="data.value" :focus="focus" :placeholder="data.placeholder" @focus="onFocus" @blur="onChange" @confirm="onConfirm" |
| | | @click="onClick" :disabled="data.disabled"></input> |
| | | <text v-if="data.setting.suffix&& !viewMode" class="form-input-icon" :class="[data.setting.suffix]" |
| | | @click="onSuffixButton"></text> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import buttonClickMixin from '@/mixins/button-click.js'; |
| | | |
| | | export default { |
| | | |
| | | name: "OIFormInput", |
| | | mixins: [buttonClickMixin], |
| | | props: { |
| | | viewMode: { |
| | | type: Boolean, |
| | |
| | | default: false |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | | largeMode: getApp().globalData?.largeMode || false, |
| | | } |
| | | }, |
| | | methods: { |
| | | onChange(e) { |
| | | this.$emit("change", e) |
| | | this.$emit("on-change", e) |
| | | }, |
| | | onConfirm(e) { |
| | | console.log("onConfirm") |
| | | this.onChange(e) |
| | | }, |
| | | onClick(e) { |
| | | this.$emit("click", e) |
| | | this.$emit("on-click", e) |
| | | }, |
| | | onFocus(e) { |
| | | this.$emit("focus", e) |
| | | // getApp().onScan((result) => { |
| | | // if (!this.viewMode && !this.data.disabled) { |
| | | // if (this.model) |
| | | // this.model[data.fieldId] = result |
| | | // else |
| | | // this.data.value = result |
| | | // } |
| | | // }) |
| | | this.$emit("on-focus", e) |
| | | }, |
| | | onPrefixButton() { |
| | | this.$emit("click-prefix") |
| | | this.handleButtonClick((done) => { |
| | | this.$emit("on-click-prefix") |
| | | setTimeout(() => { |
| | | done(); // 重置状态 |
| | | }, 1000); |
| | | }); |
| | | }, |
| | | onSuffixButton() { |
| | | this.$emit("click-suffix") |
| | | |
| | | this.handleButtonClick((done) => { |
| | | this.$emit("on-click-suffix") |
| | | setTimeout(() => { |
| | | done(); // 重置状态 |
| | | }, 1000); |
| | | }); |
| | | |
| | | |
| | | }, |
| | | } |
| | | }, |
| | | |
| | | }; |
| | | </script> |
| | | |
| | |
| | | border: 1px solid #d5d5d5; |
| | | border-radius: 6px !important; |
| | | padding: 3rpx; |
| | | width: calc(100%- 6rpx); |
| | | width: calc(100% - 6rpx); |
| | | display: flex; |
| | | flex-direction: row; |
| | | |
| | | |
| | | .input-disabled { |
| | | background-color: #f3f3f3 !important; |
| | | } |
| | |
| | | .oi-form-input:hover { |
| | | border: 1px solid rgb(41, 121, 255); |
| | | } |
| | | |
| | | .large-mode { |
| | | .oi-form-input { |
| | | .oi-input { |
| | | font-size: 24px; |
| | | height: 36px; |
| | | } |
| | | |
| | | .form-input-icon { |
| | | font-size: 30px; |
| | | height: 36px; |
| | | width: 36px; |
| | | } |
| | | } |
| | | } |
| | | </style> |