style:模具台账-筛选框逻辑调整

besure_bit
黄伟杰 2 months ago
parent 36d41897b3
commit c1899601a7

@ -10,7 +10,9 @@
type="text" type="text"
:placeholder="t('moldLedger.searchPlaceholder')" :placeholder="t('moldLedger.searchPlaceholder')"
placeholder-class="placeholder" placeholder-class="placeholder"
:focus="keywordFocus"
confirm-type="search" confirm-type="search"
@blur="keywordFocus = false"
@confirm="handleSearch" @confirm="handleSearch"
/> />
</view> </view>
@ -19,9 +21,6 @@
<uni-icons type="bottom" size="14" color="#9ca3af"></uni-icons> <uni-icons type="bottom" size="14" color="#9ca3af"></uni-icons>
</view> </view>
<view class="reset-filter-btn" @click="resetFilters">{{ t('common.reset') }}</view> <view class="reset-filter-btn" @click="resetFilters">{{ t('common.reset') }}</view>
<view class="scan-btn" @click="handleScan">
<uni-icons type="scan" size="22" color="#111827"></uni-icons>
</view>
</view> </view>
<scroll-view <scroll-view
@ -95,8 +94,8 @@
</template> </template>
<script setup> <script setup>
import { ref, computed } from 'vue' import { ref, computed, nextTick } from 'vue'
import { onLoad } from '@dcloudio/uni-app' import { onLoad, 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 CopyButton from '@/components/common/CopyButton.vue' import CopyButton from '@/components/common/CopyButton.vue'
@ -116,6 +115,7 @@ const searchKeyword = ref('')
const selectedStatus = ref(undefined) const selectedStatus = ref(undefined)
const scrollTop = ref(0) const scrollTop = ref(0)
const showGoTop = ref(false) const showGoTop = ref(false)
const keywordFocus = ref(false)
const statusOptions = computed(() => { const statusOptions = computed(() => {
const options = [] const options = []
@ -134,56 +134,24 @@ const selectedStatusLabel = computed(() => {
}) })
onLoad(async () => { onLoad(async () => {
activateKeywordFocus()
await initAllDict() await initAllDict()
await fetchList(true) await fetchList(true)
}) })
async function handleSearch() { onShow(() => {
await fetchList(true) activateKeywordFocus()
} })
async function handleScan() { function activateKeywordFocus() {
try { keywordFocus.value = false
const res = await uni.scanCode({ scanType: ['qrCode', 'barCode'] }) nextTick(() => {
const result = String(res?.result || '').trim() keywordFocus.value = true
if (!result) { })
uni.showToast({ title: t('moldLedger.scanUnrecognized'), icon: 'none' })
return
}
const scan = parseMoldScanResult(result)
if (!scan.id) {
uni.showToast({ title: t('moldLedger.scanFormatError'), icon: 'none' })
return
}
searchKeyword.value = scan.id
await fetchList(true)
} catch (error) {
const message = String(error?.errMsg || '')
if (message.includes('cancel')) return
uni.showToast({ title: t('moldLedger.scanFailed'), icon: 'none' })
}
} }
function parseMoldScanResult(result) { async function handleSearch() {
const text = String(result || '').trim() await fetchList(true)
const directMatch = text.match(/^([A-Z_]+)-(\d+)$/i)
if (directMatch) {
return {
type: directMatch[1].toUpperCase(),
id: directMatch[1].toUpperCase() === 'MOLD' ? directMatch[2] : ''
}
}
try {
const parsed = JSON.parse(text)
const type = String(parsed?.type || parsed?.bizType || parsed?.codeType || '').toUpperCase()
const id = String(parsed?.id || parsed?.moldId || parsed?.deviceId || '').trim()
return {
type,
id: type === 'MOLD' && id ? id : ''
}
} catch {
return { type: '', id: '' }
}
} }
async function clearSearch() { async function clearSearch() {
@ -194,6 +162,7 @@ async function clearSearch() {
async function resetFilters() { async function resetFilters() {
searchKeyword.value = '' searchKeyword.value = ''
selectedStatus.value = undefined selectedStatus.value = undefined
activateKeywordFocus()
await fetchList(true) await fetchList(true)
} }
@ -236,7 +205,6 @@ async function fetchList(reset) {
pageSize: pageSize.value, pageSize: pageSize.value,
code: keyword || undefined, code: keyword || undefined,
name: keyword || undefined, name: keyword || undefined,
productName: keyword || undefined,
status: selectedStatus.value status: selectedStatus.value
}) })
const page = normalizePageData(res) const page = normalizePageData(res)
@ -363,7 +331,7 @@ function formatDateTime(value) {
.filter-bar { .filter-bar {
display: grid; display: grid;
grid-template-columns: minmax(0, 1fr) 150rpx 96rpx 64rpx; grid-template-columns: minmax(0, 1fr) 150rpx 96rpx;
align-items: center; align-items: center;
gap: 14rpx; gap: 14rpx;
padding: 18rpx 28rpx 20rpx; padding: 18rpx 28rpx 20rpx;
@ -371,8 +339,7 @@ function formatDateTime(value) {
.keyword-box, .keyword-box,
.status-box, .status-box,
.reset-filter-btn, .reset-filter-btn {
.scan-btn {
height: 66rpx; height: 66rpx;
background: #ffffff; background: #ffffff;
border: 1rpx solid #d9dde5; border: 1rpx solid #d9dde5;
@ -415,10 +382,6 @@ function formatDateTime(value) {
color: #4b5563; color: #4b5563;
} }
.scan-btn {
justify-content: center;
}
.content-scroll { .content-scroll {
width: 100%; width: 100%;
} }

Loading…
Cancel
Save