style: 优化物料和备件入库供应商能够选择

master
zhongwenkai 1 day ago
parent eea217ccf8
commit 29e2c544ca

@ -91,3 +91,11 @@ export function getWarehouseSimpleList() {
method: 'get'
})
}
// 供应商列表
export function getSupplierSimpleList() {
return request({
url: '/admin-api/erp/supplier/simple-list',
method: 'get'
})
}

@ -402,6 +402,13 @@
"navigationStyle": "custom"
}
},
{
"path": "sparepartInbound/supplierSelect",
"style": {
"navigationBarTitleText": "选择供应商",
"navigationStyle": "custom"
}
},
{
"path": "productInbound/index",
"style": {

@ -207,7 +207,7 @@ async function handleSubmit() {
let totalCount = 0
const items = itemList.value.map(item => {
totalCount += item.count || 0
return { warehouseId: item.warehouseId, areaId: item.areaId, productId: item.productId, productName: item.productName, productBarCode: item.productBarCode, productUnitName: item.productUnitName, purchaseUnitName: item.purchaseUnitName, purchaseUnitConvertQuantity: item.purchaseUnitConvertQuantity, inputCount: item.inputCount, count: item.count }
return { warehouseId: item.warehouseId, areaId: item.areaId, productId: item.productId, productName: item.productName, productBarCode: item.productBarCode, productUnitName: item.productUnitName, purchaseUnitName: item.purchaseUnitName, purchaseUnitConvertQuantity: item.purchaseUnitConvertQuantity, inputCount: item.inputCount, count: item.count, supplierId: item.supplierId, supplierName: item.supplierName }
})
const now = new Date()

@ -129,11 +129,12 @@
<view class="section-bar-line"></view>
<text class="section-title">供应商</text>
</view>
<view class="select-row-card">
<view class="select-row-card" @click="openSupplierSelect">
<view class="full-dropdown">
<text :class="{ placeholder: !defaultSupplierName }">
{{ defaultSupplierName || '未配置默认供应商' }}
<text :class="{ placeholder: !currentSupplierName }">
{{ currentSupplierName || '点击选择供应商' }}
</text>
<text class="click-arrow"></text>
</view>
</view>
</view>
@ -191,6 +192,12 @@ const defaultSupplierName = computed(() => {
return firstDefault?.supplierName || ''
})
const selectedSupplierInfo = ref(null)
const currentSupplierName = computed(() => {
if (selectedSupplierInfo.value) return selectedSupplierInfo.value.name
return defaultSupplierName.value || ''
})
function textValue(v) {
if (v === 0) return '0'
if (v == null) return '-'
@ -208,6 +215,19 @@ function stockUnitLabel(item) {
return item.unitName || item.minStockUnitName || '个'
}
function getDefaultSupplierId(product) {
if (!product) return undefined
if (product.supplierId || product.supplierName) return product.supplierId
const suppliers = Array.isArray(product.suppliers) ? product.suppliers : []
const supplier = suppliers.find(s => Number(s?.defaultStatus) === 1) || suppliers[0]
if (!supplier) return undefined
return supplier.supplierId ?? supplier.id
}
function openSupplierSelect() {
uni.navigateTo({ url: '/pages_function/pages/sparepartInbound/supplierSelect' })
}
function handleCancel() {
uni.navigateBack()
}
@ -222,6 +242,7 @@ function handleConfirm() {
return
}
const defaultSid = getDefaultSupplierId(material.value)
const item = {
productId: material.value.id,
productName: material.value.name || '',
@ -231,8 +252,8 @@ function handleConfirm() {
purchaseUnitConvertQuantity: Number(material.value.purchaseUnitConvertQuantity) || 1,
inputCount: Number(inboundQty.value),
count: Number(inboundQty.value) * (Number(material.value.purchaseUnitConvertQuantity) || 1),
supplierId: material.value.defaultSupplierId,
supplierName: defaultSupplierName.value,
supplierId: selectedSupplierInfo.value ? selectedSupplierInfo.value.id : defaultSid,
supplierName: currentSupplierName.value,
warehouseId: selectedWarehouse.value.value,
warehouseName: selectedWarehouse.value.label,
areaId: selectedArea.value.value,
@ -323,6 +344,11 @@ onShow(async () => {
}
}
loadWarehouses()
const supplier = getApp().globalData._supplierSelectResult
if (supplier) {
selectedSupplierInfo.value = supplier
getApp().globalData._supplierSelectResult = null
}
})
async function loadStockCount() {
@ -412,6 +438,7 @@ onHide(() => {
.full-dropdown { display: flex; align-items: center; justify-content: space-between; width: 100%; font-size: 28rpx; color: #374151;
.placeholder { color: #9ca3af; }
}
.click-arrow { font-size: 36rpx; color: #9ca3af; }
.warehouse-area-card { align-items: flex-start; }
.warehouse-area-rows { width: 100%; display: flex; flex-direction: column; gap: 16rpx; }

@ -341,7 +341,9 @@ async function handleSubmit() {
purchaseUnitName: item.purchaseUnitName,
purchaseUnitConvertQuantity: item.purchaseUnitConvertQuantity,
inputCount: item.inputCount,
count: item.count
count: item.count,
supplierId: item.supplierId,
supplierName: item.supplierName
}
})

@ -130,11 +130,12 @@
<view class="section-bar-line"></view>
<text class="section-title">供应商</text>
</view>
<view class="select-row-card">
<view class="select-row-card" @click="openSupplierSelect">
<view class="full-dropdown">
<text :class="{ placeholder: !defaultSupplierName }">
{{ defaultSupplierName || '未配置默认供应商' }}
<text :class="{ placeholder: !currentSupplierName }">
{{ currentSupplierName || '点击选择供应商' }}
</text>
<text class="click-arrow"></text>
</view>
</view>
</view>
@ -194,6 +195,16 @@ const defaultSupplierName = computed(() => {
return firstDefault?.supplierName || ''
})
const selectedSupplierInfo = ref(null)
const currentSupplierName = computed(() => {
if (selectedSupplierInfo.value) return selectedSupplierInfo.value.name
return defaultSupplierName.value || ''
})
function openSupplierSelect() {
uni.navigateTo({ url: '/pages_function/pages/sparepartInbound/supplierSelect' })
}
function textValue(v) {
if (v === 0) return '0'
if (v == null) return '-'
@ -211,6 +222,15 @@ function stockUnitLabel(item) {
return item.unitName || item.minStockUnitName || '个'
}
function getDefaultSupplierId(product) {
if (!product) return undefined
if (product.supplierId || product.supplierName) return product.supplierId
const suppliers = Array.isArray(product.suppliers) ? product.suppliers : []
const supplier = suppliers.find(s => Number(s?.defaultStatus) === 1) || suppliers[0]
if (!supplier) return undefined
return supplier.supplierId ?? supplier.id
}
function handleCancel() {
uni.navigateBack()
}
@ -230,6 +250,7 @@ function handleConfirm() {
}
// globalData
const defaultSid = getDefaultSupplierId(sparepart.value)
const item = {
//
productId: sparepart.value.id,
@ -242,8 +263,8 @@ function handleConfirm() {
inputCount: Number(inboundQty.value),
count: Number(inboundQty.value) * (Number(sparepart.value.purchaseUnitConvertQuantity) || 1),
//
supplierId: sparepart.value.defaultSupplierId,
supplierName: defaultSupplierName.value,
supplierId: selectedSupplierInfo.value ? selectedSupplierInfo.value.id : defaultSid,
supplierName: currentSupplierName.value,
//
warehouseId: selectedWarehouse.value.value,
warehouseName: selectedWarehouse.value.label,
@ -339,6 +360,11 @@ onShow(async () => {
}
}
loadWarehouses()
const supplier = getApp().globalData._supplierSelectResult
if (supplier) {
selectedSupplierInfo.value = supplier
getApp().globalData._supplierSelectResult = null
}
})
async function loadStockCount() {
@ -433,6 +459,7 @@ onHide(() => {
.full-dropdown { display: flex; align-items: center; justify-content: space-between; width: 100%; font-size: 28rpx; color: #374151;
.placeholder { color: #9ca3af; }
}
.click-arrow { font-size: 36rpx; color: #9ca3af; }
.warehouse-area-card { align-items: flex-start; }
.warehouse-area-rows { width: 100%; display: flex; flex-direction: column; gap: 16rpx; }

@ -0,0 +1,92 @@
<template>
<view class="page-container">
<NavBar :title="'选择供应商'" />
<view class="search-bar">
<view class="search-input-wrap">
<input class="search-input" v-model="searchText" placeholder="搜索供应商名称" @input="onSearch" />
<text v-if="searchText" class="search-clear" @click="clearSearch"></text>
</view>
</view>
<scroll-view scroll-y class="list-scroll" v-if="filteredList.length > 0">
<view class="list-wrap">
<view v-for="item in filteredList" :key="item.id" class="supplier-card" :class="{ active: selectedId === item.id }" @click="handleSelect(item)">
<view class="supplier-name">{{ textValue(item.name) }}</view>
<view class="supplier-info" v-if="item.contact || item.mobile">
<text class="info-text" v-if="item.contact">{{ item.contact }}</text>
<text class="info-text" v-if="item.mobile">{{ item.mobile }}</text>
</view>
</view>
</view>
</scroll-view>
<view v-else class="empty-wrap">
<text v-if="loading" class="empty-text">...</text>
<text v-else class="empty-text">暂无供应商数据</text>
</view>
<!-- 底部确认按钮 -->
<view class="bottom-actions">
<view class="bottom-btn confirm-btn" @click="handleConfirm"></view>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import NavBar from '@/components/common/NavBar.vue'
import { getSupplierSimpleList } from '@/api/mes/sparepart'
const list = ref([])
const selectedId = ref(null)
const selectedItem = ref(null)
const searchText = ref('')
const loading = ref(false)
function textValue(v) { if (v === 0) return '0'; if (v == null) return '-'; const s = String(v).trim(); return s || '-' }
const filteredList = computed(() => {
const keyword = searchText.value.trim().toLowerCase()
if (!keyword) return list.value
return list.value.filter(s => (s.name || '').toLowerCase().includes(keyword))
})
function onSearch() {}
function clearSearch() { searchText.value = '' }
async function loadSuppliers() {
loading.value = true
try {
const res = await getSupplierSimpleList()
const root = res && res.data !== undefined ? res.data : res
list.value = Array.isArray(root) ? root : (Array.isArray(root?.data) ? root.data : [])
} catch (e) { console.error('loadSuppliers error', e) }
finally { loading.value = false }
}
function handleSelect(item) {
if (!item?.id) return
selectedId.value = item.id
selectedItem.value = item
}
function handleConfirm() {
if (!selectedItem.value) {
uni.showToast({ title: '请先选择供应商', icon: 'none' })
return
}
getApp().globalData._supplierSelectResult = selectedItem.value
uni.navigateBack()
}
onShow(() => { loadSuppliers() })
</script>
<style lang="scss" scoped>
.page-container { min-height: 100vh; background: #f5f6f8; }
.search-bar { padding: 16rpx 24rpx; background: #fff; }
.search-input-wrap { display: flex; align-items: center; height: 72rpx; padding: 0 16rpx; background: #f5f6f8; border-radius: 36rpx; }
.search-input { flex: 1; font-size: 28rpx; color: #333; }
.search-clear { font-size: 28rpx; color: #999; padding: 8rpx; }
.list-scroll { height: calc(100vh - 88rpx); }
.list-wrap { padding: 16rpx 24rpx; }
.supplier-card { background: #fff; border-radius: 14rpx; padding: 24rpx; margin-bottom: 16rpx; border: 2rpx solid transparent; }
.supplier-card.active { border-color: #2563eb; background: #f0f5ff; }
.supplier-name { font-size: 30rpx; font-weight: 700; color: #1a1a1a; }
.supplier-info { margin-top: 8rpx; display: flex; gap: 16rpx; }
.info-text { font-size: 24rpx; color: #6b7280; }
.empty-wrap { padding: 120rpx 0; text-align: center; }
.empty-text { font-size: 28rpx; color: #999; }
.bottom-actions { position: fixed; left: 0; right: 0; bottom: 0; padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom)); background: #ffffff; box-shadow: 0 -8rpx 24rpx rgba(15, 23, 42, 0.06); z-index: 99; }
.bottom-btn { width: 100%; height: 84rpx; line-height: 84rpx; text-align: center; border-radius: 16rpx; font-size: 30rpx; font-weight: 600; }
.bottom-btn.confirm-btn { background: #1f4b79; color: #ffffff; }
</style>
Loading…
Cancel
Save