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

master
黄伟杰 3 days ago
parent 36d41897b3
commit c1899601a7

@ -10,7 +10,9 @@
type="text"
:placeholder="t('moldLedger.searchPlaceholder')"
placeholder-class="placeholder"
:focus="keywordFocus"
confirm-type="search"
@blur="keywordFocus = false"
@confirm="handleSearch"
/>
</view>
@ -19,9 +21,6 @@
<uni-icons type="bottom" size="14" color="#9ca3af"></uni-icons>
</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>
<scroll-view
@ -95,8 +94,8 @@
</template>
<script setup>
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { ref, computed, nextTick } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import CopyButton from '@/components/common/CopyButton.vue'
@ -116,6 +115,7 @@ const searchKeyword = ref('')
const selectedStatus = ref(undefined)
const scrollTop = ref(0)
const showGoTop = ref(false)
const keywordFocus = ref(false)
const statusOptions = computed(() => {
const options = []
@ -134,56 +134,24 @@ const selectedStatusLabel = computed(() => {
})
onLoad(async () => {
activateKeywordFocus()
await initAllDict()
await fetchList(true)
})
async function handleSearch() {
await fetchList(true)
}
onShow(() => {
activateKeywordFocus()
})
async function handleScan() {
try {
const res = await uni.scanCode({ scanType: ['qrCode', 'barCode'] })
const result = String(res?.result || '').trim()
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 activateKeywordFocus() {
keywordFocus.value = false
nextTick(() => {
keywordFocus.value = true
})
}
function parseMoldScanResult(result) {
const text = String(result || '').trim()
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 handleSearch() {
await fetchList(true)
}
async function clearSearch() {
@ -194,6 +162,7 @@ async function clearSearch() {
async function resetFilters() {
searchKeyword.value = ''
selectedStatus.value = undefined
activateKeywordFocus()
await fetchList(true)
}
@ -236,7 +205,6 @@ async function fetchList(reset) {
pageSize: pageSize.value,
code: keyword || undefined,
name: keyword || undefined,
productName: keyword || undefined,
status: selectedStatus.value
})
const page = normalizePageData(res)
@ -363,7 +331,7 @@ function formatDateTime(value) {
.filter-bar {
display: grid;
grid-template-columns: minmax(0, 1fr) 150rpx 96rpx 64rpx;
grid-template-columns: minmax(0, 1fr) 150rpx 96rpx;
align-items: center;
gap: 14rpx;
padding: 18rpx 28rpx 20rpx;
@ -371,8 +339,7 @@ function formatDateTime(value) {
.keyword-box,
.status-box,
.reset-filter-btn,
.scan-btn {
.reset-filter-btn {
height: 66rpx;
background: #ffffff;
border: 1rpx solid #d9dde5;
@ -415,10 +382,6 @@ function formatDateTime(value) {
color: #4b5563;
}
.scan-btn {
justify-content: center;
}
.content-scroll {
width: 100%;
}

Loading…
Cancel
Save