feat:模具点检、保养、维修单-输入框优化

besure_bit
黄伟杰 2 weeks ago
parent 079ecfb861
commit 19c890bf0e

@ -4,7 +4,7 @@
<view class="filter-bar"> <view class="filter-bar">
<view class="keyword-box"> <view class="keyword-box">
<input v-model="searchKeyword" class="keyword-input" :placeholder="t('moldCheck.searchPlaceholder')" <input id="mold-check-keyword-input" v-model="searchKeyword" class="keyword-input" :placeholder="t('moldCheck.searchPlaceholder')"
:focus="keywordFocus" confirm-type="search" @blur="keywordFocus = false" @input="handleKeywordInput" :focus="keywordFocus" confirm-type="search" @blur="keywordFocus = false" @input="handleKeywordInput"
@confirm="handleSearch" /> @confirm="handleSearch" />
</view> </view>
@ -72,12 +72,14 @@
<view class="add-btn" @click="goAdd"> <view class="add-btn" @click="goAdd">
<text class="add-icon">+</text> <text class="add-icon">+</text>
</view> </view>
<sv-focus-no-keyboard ref="focusNoKeyboardRef"></sv-focus-no-keyboard>
</view> </view>
</template> </template>
<script setup> <script setup>
import { computed, nextTick, ref } from 'vue' import { computed, nextTick, ref } from 'vue'
import { onLoad, onReachBottom, onShow, onUnload } from '@dcloudio/uni-app' import { onLoad, onReady, onReachBottom, onShow, onUnload } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue' import NavBar from '@/components/common/NavBar.vue'
import { getMoldCheckPage } from '@/api/mes/moldCheck' import { getMoldCheckPage } from '@/api/mes/moldCheck'
@ -96,6 +98,8 @@ const pageSize = ref(10)
const scrollTop = ref(0) const scrollTop = ref(0)
const showGoTop = ref(false) const showGoTop = ref(false)
const keywordFocus = ref(false) const keywordFocus = ref(false)
const focusNoKeyboardRef = ref(null)
const keywordInputSelector = '#mold-check-keyword-input input, input#mold-check-keyword-input'
let searchTimer = null let searchTimer = null
@ -125,8 +129,11 @@ onLoad(async () => {
await fetchList(true) await fetchList(true)
}) })
onReady(() => {
focusKeywordNoKeyboard()
})
onShow(() => { onShow(() => {
activateKeywordFocus()
if (uni.getStorageSync('moldCheckListNeedRefresh') === '1') { if (uni.getStorageSync('moldCheckListNeedRefresh') === '1') {
uni.removeStorageSync('moldCheckListNeedRefresh') uni.removeStorageSync('moldCheckListNeedRefresh')
fetchList(true) fetchList(true)
@ -250,6 +257,14 @@ function activateKeywordFocus() {
}) })
} }
function focusKeywordNoKeyboard() {
nextTick(() => {
setTimeout(() => {
focusNoKeyboardRef.value?.focus(keywordInputSelector)
}, 80)
})
}
function clearSearchTimer() { function clearSearchTimer() {
if (searchTimer) { if (searchTimer) {
clearTimeout(searchTimer) clearTimeout(searchTimer)
@ -557,4 +572,4 @@ function formatDateTime(value) {
line-height: 1; line-height: 1;
margin-top: -4rpx; margin-top: -4rpx;
} }
</style> </style>

@ -4,7 +4,7 @@
<view class="filter-bar"> <view class="filter-bar">
<view class="keyword-box"> <view class="keyword-box">
<input v-model="searchKeyword" class="keyword-input" :placeholder="t('moldMaintain.searchPlaceholder')" <input id="mold-maintain-keyword-input" v-model="searchKeyword" class="keyword-input" :placeholder="t('moldMaintain.searchPlaceholder')"
:focus="keywordFocus" confirm-type="search" @blur="keywordFocus = false" @input="handleKeywordInput" :focus="keywordFocus" confirm-type="search" @blur="keywordFocus = false" @input="handleKeywordInput"
@confirm="handleSearch" /> @confirm="handleSearch" />
</view> </view>
@ -72,12 +72,14 @@
<view class="add-btn" @click="goAdd"> <view class="add-btn" @click="goAdd">
<text class="add-icon">+</text> <text class="add-icon">+</text>
</view> </view>
<sv-focus-no-keyboard ref="focusNoKeyboardRef"></sv-focus-no-keyboard>
</view> </view>
</template> </template>
<script setup> <script setup>
import { computed, nextTick, ref } from 'vue' import { computed, nextTick, ref } from 'vue'
import { onLoad, onReachBottom, onShow, onUnload } from '@dcloudio/uni-app' import { onLoad, onReady, onReachBottom, onShow, onUnload } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue' import NavBar from '@/components/common/NavBar.vue'
import { getMoldCheckPage } from '@/api/mes/moldCheck' import { getMoldCheckPage } from '@/api/mes/moldCheck'
@ -96,6 +98,8 @@ const pageSize = ref(10)
const scrollTop = ref(0) const scrollTop = ref(0)
const showGoTop = ref(false) const showGoTop = ref(false)
const keywordFocus = ref(false) const keywordFocus = ref(false)
const focusNoKeyboardRef = ref(null)
const keywordInputSelector = '#mold-maintain-keyword-input input, input#mold-maintain-keyword-input'
let searchTimer = null let searchTimer = null
@ -125,8 +129,11 @@ onLoad(async () => {
await fetchList(true) await fetchList(true)
}) })
onReady(() => {
focusKeywordNoKeyboard()
})
onShow(() => { onShow(() => {
activateKeywordFocus()
if (uni.getStorageSync('moldMaintainListNeedRefresh') === '1') { if (uni.getStorageSync('moldMaintainListNeedRefresh') === '1') {
uni.removeStorageSync('moldMaintainListNeedRefresh') uni.removeStorageSync('moldMaintainListNeedRefresh')
fetchList(true) fetchList(true)
@ -250,6 +257,14 @@ function activateKeywordFocus() {
}) })
} }
function focusKeywordNoKeyboard() {
nextTick(() => {
setTimeout(() => {
focusNoKeyboardRef.value?.focus(keywordInputSelector)
}, 80)
})
}
function clearSearchTimer() { function clearSearchTimer() {
if (searchTimer) { if (searchTimer) {
clearTimeout(searchTimer) clearTimeout(searchTimer)

@ -5,6 +5,7 @@
<view class="filter-bar"> <view class="filter-bar">
<view class="keyword-box"> <view class="keyword-box">
<input <input
id="mold-repair-keyword-input"
v-model="searchKeyword" v-model="searchKeyword"
class="keyword-input" class="keyword-input"
type="text" type="text"
@ -79,12 +80,14 @@
<view class="add-btn" @click="openForm('create')"> <view class="add-btn" @click="openForm('create')">
<text class="add-icon">+</text> <text class="add-icon">+</text>
</view> </view>
<sv-focus-no-keyboard ref="focusNoKeyboardRef"></sv-focus-no-keyboard>
</view> </view>
</template> </template>
<script setup> <script setup>
import { computed, nextTick, ref } from 'vue' import { computed, nextTick, ref } from 'vue'
import { onLoad, onReachBottom, onShow } from '@dcloudio/uni-app' import { onLoad, onReady, onReachBottom, onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue' import NavBar from '@/components/common/NavBar.vue'
import { import {
@ -107,6 +110,8 @@ const scrollTop = ref(0)
const showGoTop = ref(false) const showGoTop = ref(false)
const keywordFocus = ref(false) const keywordFocus = ref(false)
const selectedMoldId = ref('') const selectedMoldId = ref('')
const focusNoKeyboardRef = ref(null)
const keywordInputSelector = '#mold-repair-keyword-input input, input#mold-repair-keyword-input'
const statusOptions = computed(() => [ const statusOptions = computed(() => [
{ label: t('functionCommon.all'), value: '' }, { label: t('functionCommon.all'), value: '' },
@ -127,12 +132,14 @@ const selectedStatusLabel = computed(() => {
onLoad(async () => { onLoad(async () => {
initialized.value = true initialized.value = true
activateKeywordFocus()
await fetchList(true) await fetchList(true)
}) })
onReady(() => {
focusKeywordNoKeyboard()
})
onShow(async () => { onShow(async () => {
activateKeywordFocus()
if (!initialized.value) return if (!initialized.value) return
await fetchList(true) await fetchList(true)
}) })
@ -195,6 +202,14 @@ function activateKeywordFocus() {
}) })
} }
function focusKeywordNoKeyboard() {
nextTick(() => {
setTimeout(() => {
focusNoKeyboardRef.value?.focus(keywordInputSelector)
}, 80)
})
}
function handleSearch() { function handleSearch() {
uni.hideKeyboard() uni.hideKeyboard()
fetchList(true) fetchList(true)
@ -553,4 +568,4 @@ function textValue(value) {
line-height: 1; line-height: 1;
margin-top: -4rpx; margin-top: -4rpx;
} }
</style> </style>

Loading…
Cancel
Save