style: 模具台账产品下拉框筛选修复

master
zhongwenkai 1 day ago
parent 3a28dad83c
commit a457da530c

@ -16,10 +16,11 @@ export function getProductSimpleList(params) {
})
}
export function getMesProductSimpleList() {
export function getMesProductSimpleList(params) {
return request({
url: '/admin-api/erp/product/simple-list-product',
method: 'get'
method: 'get',
params
})
}

@ -25,9 +25,10 @@ export function getItemList() {
}
// 产品简单列表(用于下拉选择)
export function getMesProductSimpleList() {
export function getMesProductSimpleList(params) {
return request({
url: '/admin-api/erp/product/simple-list-product',
method: 'get'
method: 'get',
params
})
}

@ -94,18 +94,18 @@
<view class="drawer-field">
<text class="drawer-label">{{ t('moldLedger.productModel') }}</text>
<view class="drawer-picker" @click="toggleProductPanel">
<text :class="['drawer-picker-text', selectedProductIds.length === 0 ? 'placeholder' : '']">{{ selectedProductLabel }}</text>
<text :class="['drawer-picker-text', selectedProductId == null ? 'placeholder' : '']">{{ selectedProductLabel }}</text>
<uni-icons type="bottom" size="14" color="#9ca3af"></uni-icons>
</view>
<scroll-view v-if="productPanelOpen" scroll-y class="drawer-option-panel">
<view
v-for="item in productOptions"
:key="item.id"
:class="['drawer-option-item', selectedProductIds.includes(item.id) ? 'active' : '']"
:class="['drawer-option-item', selectedProductId === item.id ? 'active' : '']"
@click="selectProduct(item)"
>
<text class="drawer-option-text">{{ item.name }}</text>
<text v-if="selectedProductIds.includes(item.id)" class="drawer-option-check"></text>
<text v-if="selectedProductId === item.id" class="drawer-option-check"></text>
</view>
</scroll-view>
</view>
@ -163,7 +163,7 @@ const searchKeyword = ref('')
const selectedStatus = ref('')
const productOptions = ref([])
const deviceOptions = ref([])
const selectedProductIds = ref([])
const selectedProductId = ref(null)
const selectedCurrentDevice = ref('')
//
const productPanelOpen = ref(false)
@ -196,11 +196,9 @@ const selectedStatusLabel = computed(() => {
})
const selectedProductLabel = computed(() => {
if (selectedProductIds.value.length === 0) return t('moldLedger.productModel')
const names = productOptions.value
.filter((p) => selectedProductIds.value.includes(p.id))
.map((p) => p.name)
return names.join(', ') || t('moldLedger.productModel')
if (selectedProductId.value == null) return t('moldLedger.productModel')
const found = productOptions.value.find((p) => p.id === selectedProductId.value)
return found ? found.name : t('moldLedger.productModel')
})
const selectedDeviceLabel = computed(() => {
@ -225,7 +223,7 @@ onReady(() => {
async function fetchProductOptions() {
try {
const res = await getMesProductSimpleList()
const res = await getMesProductSimpleList({ type: '1', categoryType: '1' })
const root = res && res.data !== undefined ? res.data : res
productOptions.value = Array.isArray(root) ? root : (root?.data || [])
} catch { productOptions.value = [] }
@ -261,12 +259,8 @@ function toggleDevicePanel() {
}
function selectProduct(item) {
const idx = selectedProductIds.value.indexOf(item.id)
if (idx >= 0) {
selectedProductIds.value.splice(idx, 1)
} else {
selectedProductIds.value.push(item.id)
}
selectedProductId.value = selectedProductId.value === item.id ? null : item.id
productPanelOpen.value = false
}
function selectDevice(item) {
@ -282,7 +276,7 @@ function confirmFilterDrawer() {
async function resetFilters() {
searchKeyword.value = ''
selectedStatus.value = ''
selectedProductIds.value = []
selectedProductId.value = null
selectedCurrentDevice.value = ''
await fetchList(true)
}
@ -315,10 +309,7 @@ async function fetchList(reset) {
code: keyword || undefined,
name: keyword || undefined,
status: selectedStatus.value,
productIds: selectedProductIds.value.length ? selectedProductIds.value : undefined,
productName: selectedProductIds.value.length
? productOptions.value.filter((p) => selectedProductIds.value.includes(p.id)).map((p) => p.name).join(',')
: undefined,
productId: selectedProductId.value != null ? selectedProductId.value : undefined,
currentDevice: selectedCurrentDevice.value || undefined
})
const page = normalizePageData(res)
@ -522,6 +513,7 @@ function formatDateTime(value) {
.content-scroll {
width: 100%;
height: calc(100vh - var(--status-bar-height) - 88rpx - 188rpx);
}
.list-wrap {

Loading…
Cancel
Save