fix: 李红攀:V2.0.008采购入库库位推荐的同步
This commit is contained in:
@@ -74,9 +74,17 @@
|
||||
<text class="text-28rpx text-[#333] font-semibold">{{ item.productName || '-' }}</text>
|
||||
<text v-if="item.productBarCode" class="ml-12rpx text-22rpx text-[#999]">{{ item.productBarCode }}</text>
|
||||
</view>
|
||||
<text v-if="item.warehouseName" class="text-24rpx text-[#1890ff]">{{ item.warehouseName }}</text>
|
||||
<view class="flex items-center">
|
||||
<text v-if="item.warehouseName" class="text-24rpx text-[#1890ff]">{{ item.warehouseName }}</text>
|
||||
<text v-if="item.locationCode" class="ml-8rpx text-22rpx text-[#52c41a]">[{{ item.locationCode }}]</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="p-24rpx">
|
||||
<!-- 批次号 -->
|
||||
<view v-if="item.batchNo" class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<text class="mr-8rpx text-[#999]">批次号:</text>
|
||||
<text class="text-[#e6a23c]">{{ item.batchNo }}</text>
|
||||
</view>
|
||||
<!-- 产品规格 -->
|
||||
<view v-if="item.productSpec" class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<text class="mr-8rpx text-[#999]">规格:</text>
|
||||
@@ -170,15 +178,19 @@
|
||||
<!-- 审核弹窗 -->
|
||||
<wd-popup v-model="auditVisible" position="bottom" closable @close="auditVisible = false">
|
||||
<view class="p-32rpx">
|
||||
<view class="text-32rpx text-[#333] font-semibold mb-32rpx text-center">
|
||||
<view class="mb-32rpx text-center text-32rpx text-[#333] font-semibold">
|
||||
采购入库审核
|
||||
</view>
|
||||
<view class="mb-24rpx">
|
||||
<view class="text-26rpx text-[#666] mb-12rpx">是否合格</view>
|
||||
<view class="mb-12rpx text-26rpx text-[#666]">
|
||||
是否合格
|
||||
</view>
|
||||
<wd-switch v-model="auditForm.isQualified" @change="handleQualifiedChange" />
|
||||
</view>
|
||||
<view v-if="!auditForm.isQualified" class="mb-24rpx">
|
||||
<view class="text-26rpx text-[#666] mb-12rpx">返回方式</view>
|
||||
<view class="mb-12rpx text-26rpx text-[#666]">
|
||||
返回方式
|
||||
</view>
|
||||
<wd-radio-group v-model="auditForm.returnType" shape="button">
|
||||
<wd-radio
|
||||
v-for="opt in RETURN_TYPE_OPTIONS"
|
||||
@@ -190,14 +202,16 @@
|
||||
</wd-radio-group>
|
||||
</view>
|
||||
<view v-if="!auditForm.isQualified" class="mb-24rpx">
|
||||
<view class="text-26rpx text-[#666] mb-12rpx">返回备注</view>
|
||||
<view class="mb-12rpx text-26rpx text-[#666]">
|
||||
返回备注
|
||||
</view>
|
||||
<wd-textarea
|
||||
v-model="auditForm.returnRemark"
|
||||
placeholder="请输入返回方式备注"
|
||||
:maxlength="200"
|
||||
/>
|
||||
</view>
|
||||
<view class="flex gap-24rpx mt-32rpx">
|
||||
<view class="mt-32rpx flex gap-24rpx">
|
||||
<wd-button class="flex-1" plain @click="auditVisible = false">
|
||||
取消
|
||||
</wd-button>
|
||||
@@ -246,23 +260,30 @@ const auditForm = reactive({
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number, isQualified?: boolean) {
|
||||
if (status === 10) return '未审核'
|
||||
if (status === 20) return isQualified ? '已审核' : '不合格'
|
||||
if (status === 30) return '不合格'
|
||||
if (status === 10)
|
||||
return '未审核'
|
||||
if (status === 20)
|
||||
return isQualified ? '已审核' : '不合格'
|
||||
if (status === 30)
|
||||
return '不合格'
|
||||
return '未知'
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number, isQualified?: boolean) {
|
||||
if (status === 10) return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
if (status === 20) return isQualified ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff1f0] text-[#f5222d]'
|
||||
if (status === 30) return 'bg-[#fff1f0] text-[#f5222d]'
|
||||
if (status === 10)
|
||||
return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
if (status === 20)
|
||||
return isQualified ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff1f0] text-[#f5222d]'
|
||||
if (status === 30)
|
||||
return 'bg-[#fff1f0] text-[#f5222d]'
|
||||
return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
|
||||
/** 获取返回方式标签 */
|
||||
function getReturnTypeLabel(value?: string | null) {
|
||||
if (!value) return '-'
|
||||
if (!value)
|
||||
return '-'
|
||||
const option = RETURN_TYPE_OPTIONS.find(opt => opt.value === value)
|
||||
return option ? option.label : value
|
||||
}
|
||||
@@ -310,7 +331,8 @@ function handleQualifiedChange(val: boolean) {
|
||||
|
||||
/** 提交审核 */
|
||||
async function submitAudit() {
|
||||
if (!props.id) return
|
||||
if (!props.id)
|
||||
return
|
||||
if (!auditForm.isQualified && !auditForm.returnType) {
|
||||
toast.warning('请选择返回方式')
|
||||
return
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
placeholder="请选择入库时间"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="关联订单" title-width="180rpx" center is-link @click="openOrderSelect">
|
||||
<wd-cell title="关联订单" title-width="180rpx" is-link center @click="openOrderSelect">
|
||||
<text v-if="formData.orderNo" class="text-[#1890ff]">{{ formData.orderNo }}</text>
|
||||
<text v-else class="text-[#999]">点击选择采购订单</text>
|
||||
</wd-cell>
|
||||
@@ -97,12 +97,25 @@
|
||||
>
|
||||
<view class="flex items-center justify-between bg-[#f8f8f8] px-24rpx py-12rpx">
|
||||
<text class="text-28rpx text-[#333] font-semibold">产品 #{{ index + 1 }} {{ item.productName || '' }}</text>
|
||||
<wd-button
|
||||
v-if="formData.items && formData.items.length > 1"
|
||||
size="small" type="error" plain @click="handleRemoveItem(index)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
<view class="flex gap-12rpx">
|
||||
<wd-button
|
||||
v-if="isLocationEnabled(item.warehouseId)"
|
||||
size="small" type="primary" plain @click="handleRecommendLocation(item, index)"
|
||||
>
|
||||
推荐货位
|
||||
</wd-button>
|
||||
<wd-button
|
||||
size="small" type="warning" plain @click="handleSplit(index)"
|
||||
>
|
||||
拆分
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="formData.items && formData.items.length > 1"
|
||||
size="small" type="error" plain @click="handleRemoveItem(index)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="p-24rpx">
|
||||
<!-- 仓库选择 -->
|
||||
@@ -115,6 +128,24 @@
|
||||
@confirm="(e: any) => onWarehouseConfirm(e, index)"
|
||||
/>
|
||||
</view>
|
||||
<!-- 库位编码 -->
|
||||
<view v-if="isLocationEnabled(item.warehouseId)" class="mb-16rpx">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">库位编码</text>
|
||||
<wd-input
|
||||
v-model="item.locationCode"
|
||||
placeholder="库房号-区域-货位号,如 1-A-01"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<!-- 批次号 -->
|
||||
<view class="mb-16rpx">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">批次号</text>
|
||||
<wd-input
|
||||
v-model="item.batchNo"
|
||||
placeholder="请输入批次号"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<!-- 自动填充的产品信息(只读) -->
|
||||
<view v-if="item.productId" class="mb-16rpx rounded-8rpx bg-[#f9f9f9] p-16rpx">
|
||||
<view class="mb-8rpx flex justify-between text-24rpx">
|
||||
@@ -232,7 +263,9 @@
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<view class="text-30rpx text-[#333] font-semibold">{{ item.no }}</view>
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.no }}
|
||||
</view>
|
||||
<wd-icon v-if="selectedOrderId === item.id" name="check" color="#1890ff" size="40rpx" />
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
@@ -241,20 +274,32 @@
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">产品</text>
|
||||
<text class="ml-16rpx line-clamp-1 text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
|
||||
<text class="line-clamp-1 ml-16rpx text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
|
||||
</view>
|
||||
<view class="flex items-center justify-around mt-12rpx pt-12rpx border-t border-[#f0f0f0]">
|
||||
<view class="mt-12rpx flex items-center justify-around border-t border-[#f0f0f0] pt-12rpx">
|
||||
<view class="text-center">
|
||||
<view class="text-28rpx text-[#333] font-semibold">{{ item.totalCount || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999]">总数量</view>
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.totalCount || 0 }}
|
||||
</view>
|
||||
<view class="text-22rpx text-[#999]">
|
||||
总数量
|
||||
</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-28rpx text-[#52c41a] font-semibold">{{ item.inCount || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999]">已入库</view>
|
||||
<view class="text-28rpx text-[#52c41a] font-semibold">
|
||||
{{ item.inCount || 0 }}
|
||||
</view>
|
||||
<view class="text-22rpx text-[#999]">
|
||||
已入库
|
||||
</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-28rpx text-[#e6a23c] font-semibold">¥{{ item.totalPrice || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999]">含税金额</view>
|
||||
<view class="text-28rpx text-[#e6a23c] font-semibold">
|
||||
¥{{ item.totalPrice || 0 }}
|
||||
</view>
|
||||
<view class="text-22rpx text-[#999]">
|
||||
含税金额
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -301,6 +346,9 @@ interface WarehouseSimple {
|
||||
id: number
|
||||
name: string
|
||||
defaultStatus?: boolean
|
||||
enableLocation?: boolean
|
||||
roomNoMax?: number
|
||||
locationCapacity?: number
|
||||
}
|
||||
|
||||
/** 供应商简单信息 */
|
||||
@@ -370,9 +418,19 @@ const warehouseColumns = computed(() => [
|
||||
warehouseList.value.map(w => ({ value: w.id, label: w.name })),
|
||||
])
|
||||
|
||||
/** 判断仓库是否启用库位管理 */
|
||||
function isLocationEnabled(warehouseId?: number): boolean {
|
||||
if (!warehouseId)
|
||||
return false
|
||||
const warehouse = warehouseList.value.find(w => w.id === warehouseId)
|
||||
console.log('[库位推荐] warehouseId:', warehouseId, 'warehouse:', warehouse, 'enableLocation:', warehouse?.enableLocation)
|
||||
return warehouse?.enableLocation === true
|
||||
}
|
||||
|
||||
/** 获取供应商名称 */
|
||||
function getSupplierName() {
|
||||
if (!formData.value.supplierId) return ''
|
||||
if (!formData.value.supplierId)
|
||||
return ''
|
||||
const supplier = supplierList.value.find(s => s.id === formData.value.supplierId)
|
||||
return supplier?.name || formData.value.supplierName || ''
|
||||
}
|
||||
@@ -383,12 +441,21 @@ function onAccountConfirm({ value }: any) {
|
||||
}
|
||||
|
||||
/** 仓库选择回调 */
|
||||
function onWarehouseConfirm({ value }: any, index: number) {
|
||||
function onWarehouseConfirm(e: any, index: number) {
|
||||
console.log('[仓库选择] 完整事件:', e, 'index:', index)
|
||||
if (formData.value.items && formData.value.items[index]) {
|
||||
formData.value.items[index].warehouseId = value?.[0]
|
||||
const warehouse = warehouseList.value.find(w => w.id === value?.[0])
|
||||
// wd-picker 的 confirm 事件返回 { value, selectedItems }
|
||||
const warehouseId = e?.value?.[0] ?? e?.selectedItems?.[0]?.value ?? formData.value.items[index].warehouseId
|
||||
console.log('[仓库选择] 解析后 warehouseId:', warehouseId)
|
||||
formData.value.items[index].warehouseId = warehouseId
|
||||
const warehouse = warehouseList.value.find(w => w.id === warehouseId)
|
||||
console.log('[仓库选择] 找到仓库:', warehouse)
|
||||
if (warehouse) {
|
||||
formData.value.items[index].warehouseName = warehouse.name
|
||||
// 如果仓库未启用库位管理,清空库位编码
|
||||
if (!warehouse.enableLocation) {
|
||||
formData.value.items[index].locationCode = undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -407,7 +474,8 @@ function calcTotalPrice(item: PurchaseInItem) {
|
||||
watch(
|
||||
() => formData.value,
|
||||
(val) => {
|
||||
if (!val || !val.items) return
|
||||
if (!val || !val.items)
|
||||
return
|
||||
// 计算每个明细的金额
|
||||
val.items.forEach((item) => {
|
||||
if (item.productPrice && item.count) {
|
||||
@@ -437,6 +505,7 @@ async function loadDropdownData() {
|
||||
supplierList.value = suppliers || []
|
||||
accountList.value = accounts || []
|
||||
warehouseList.value = warehouses || []
|
||||
console.log('[仓库数据] warehouseList:', warehouseList.value)
|
||||
// 设置默认账户
|
||||
const defaultAccount = accountList.value.find(a => a.defaultStatus)
|
||||
if (defaultAccount && !formData.value.accountId) {
|
||||
@@ -467,6 +536,135 @@ function handleRemoveItem(index: number) {
|
||||
})
|
||||
}
|
||||
|
||||
/** 拆分明细行:复制当前产品行为一条新行,用于“同一产品分多个库位”录入 */
|
||||
function handleSplit(index: number) {
|
||||
const sourceItem = formData.value.items?.[index]
|
||||
if (!sourceItem)
|
||||
return
|
||||
|
||||
const newItem: PurchaseInItem = {
|
||||
...sourceItem,
|
||||
id: undefined,
|
||||
locationCode: sourceItem.locationCode,
|
||||
batchNo: sourceItem.batchNo,
|
||||
count: sourceItem.count,
|
||||
totalProductPrice: undefined,
|
||||
taxPrice: undefined,
|
||||
totalPrice: undefined,
|
||||
remark: undefined,
|
||||
}
|
||||
formData.value.items?.splice(index + 1, 0, newItem)
|
||||
toast.success('已拆分,请调整数量和库位')
|
||||
}
|
||||
|
||||
/** 推荐货位 */
|
||||
async function handleRecommendLocation(item: PurchaseInItem, index: number) {
|
||||
console.log('[推荐货位] 开始, item:', item, 'index:', index)
|
||||
if (!item.warehouseId) {
|
||||
toast.warning('请先选择仓库')
|
||||
return
|
||||
}
|
||||
if (!item.productId) {
|
||||
toast.warning('请先选择产品')
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.warning('请先填写有效数量')
|
||||
return
|
||||
}
|
||||
|
||||
const warehouse = warehouseList.value.find(w => w.id === item.warehouseId)
|
||||
console.log('[推荐货位] 仓库:', warehouse, 'locationCapacity:', warehouse?.locationCapacity)
|
||||
const locationCapacity = warehouse?.locationCapacity || 0
|
||||
if (locationCapacity <= 0) {
|
||||
toast.warning('当前仓库未配置单货位容量,无法推荐货位')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
toast.loading('正在推荐货位...')
|
||||
const { http } = await import('@/http/http')
|
||||
const totalCount = Number(item.count)
|
||||
const requiredLocationCount = Math.ceil(totalCount / locationCapacity)
|
||||
|
||||
const recommendList = await http.get<string[]>('/erp/location/recommend-inbound', {
|
||||
productId: item.productId,
|
||||
warehouseId: item.warehouseId,
|
||||
count: totalCount,
|
||||
topN: requiredLocationCount,
|
||||
})
|
||||
|
||||
if (!recommendList || recommendList.length === 0) {
|
||||
toast.warning('当前没有可推荐的空货位,请手工选择')
|
||||
return
|
||||
}
|
||||
|
||||
// 单个货位直接回填
|
||||
if (recommendList.length === 1) {
|
||||
item.locationCode = recommendList[0]
|
||||
toast.success(`已推荐货位: ${recommendList[0]}`)
|
||||
return
|
||||
}
|
||||
|
||||
// 多个货位,提示用户选择或自动拆分
|
||||
uni.showModal({
|
||||
title: '推荐货位',
|
||||
content: `需要 ${requiredLocationCount} 个货位,推荐: ${recommendList.join(', ')}\n是否自动拆分并分配?`,
|
||||
confirmText: '自动拆分',
|
||||
cancelText: '手动填写',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
// 自动拆分
|
||||
applyAutoSplit(index, recommendList, locationCapacity)
|
||||
} else {
|
||||
// 只填写第一个货位
|
||||
item.locationCode = recommendList[0]
|
||||
toast.info(`已填写第一个货位: ${recommendList[0]},请手动拆分其他`)
|
||||
}
|
||||
},
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('推荐货位失败', error)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 自动拆分并分配货位 */
|
||||
function applyAutoSplit(index: number, locationCodes: string[], locationCapacity: number) {
|
||||
const sourceItem = formData.value.items?.[index]
|
||||
if (!sourceItem)
|
||||
return
|
||||
|
||||
const totalCount = Number(sourceItem.count)
|
||||
let remaining = totalCount
|
||||
|
||||
// 更新第一行
|
||||
const firstCount = Math.min(remaining, locationCapacity)
|
||||
sourceItem.locationCode = locationCodes[0]
|
||||
sourceItem.count = Number(firstCount.toFixed(4))
|
||||
remaining = Number((remaining - firstCount).toFixed(4))
|
||||
|
||||
// 插入后续行
|
||||
for (let i = 1; i < locationCodes.length && remaining > 0; i++) {
|
||||
const currentCount = Math.min(remaining, locationCapacity)
|
||||
const newItem: PurchaseInItem = {
|
||||
...sourceItem,
|
||||
id: undefined,
|
||||
locationCode: locationCodes[i],
|
||||
count: Number(currentCount.toFixed(4)),
|
||||
totalProductPrice: undefined,
|
||||
taxPrice: undefined,
|
||||
totalPrice: undefined,
|
||||
remark: undefined,
|
||||
}
|
||||
formData.value.items?.splice(index + i, 0, newItem)
|
||||
remaining = Number((remaining - currentCount).toFixed(4))
|
||||
}
|
||||
|
||||
toast.success(`已自动拆分为 ${locationCodes.length} 个货位`)
|
||||
}
|
||||
|
||||
/** 打开订单选择弹窗 */
|
||||
function openOrderSelect() {
|
||||
orderSelectVisible.value = true
|
||||
@@ -495,7 +693,8 @@ async function getOrderList() {
|
||||
|
||||
/** 加载更多订单 */
|
||||
function loadMoreOrders() {
|
||||
if (orderLoadMoreState.value === 'finished') return
|
||||
if (orderLoadMoreState.value === 'finished')
|
||||
return
|
||||
orderQueryParams.value.pageNo++
|
||||
getOrderList()
|
||||
}
|
||||
@@ -507,7 +706,8 @@ function handleSelectOrder(item: PurchaseOrder) {
|
||||
|
||||
/** 确认选择订单 */
|
||||
async function confirmSelectOrder() {
|
||||
if (!selectedOrderId.value) return
|
||||
if (!selectedOrderId.value)
|
||||
return
|
||||
try {
|
||||
toast.loading('加载订单详情...')
|
||||
const orderDetail = await getPurchaseOrder(selectedOrderId.value)
|
||||
|
||||
@@ -11,18 +11,18 @@
|
||||
<SearchForm @search="handleQuery" @reset="handleReset" />
|
||||
|
||||
<!-- 状态快速筛选 -->
|
||||
<view class="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view class="mx-24rpx mb-16rpx flex items-center overflow-hidden rounded-12rpx bg-white shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
class="relative flex-1 py-20rpx text-center text-26rpx"
|
||||
:class="activeStatus === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'"
|
||||
@click="handleQuickFilter(tab.value)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<view
|
||||
v-if="activeStatus === tab.value"
|
||||
class="absolute bottom-0 left-1/4 w-1/2 h-4rpx rounded-2rpx bg-[#1890ff]"
|
||||
class="absolute bottom-0 left-1/4 h-4rpx w-1/2 rounded-2rpx bg-[#1890ff]"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
@@ -56,7 +56,7 @@
|
||||
<!-- 产品 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">产品</text>
|
||||
<text class="ml-16rpx line-clamp-1 text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
|
||||
<text class="line-clamp-1 ml-16rpx text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
|
||||
</view>
|
||||
<!-- 入库时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
@@ -64,23 +64,40 @@
|
||||
<text>{{ formatDate(item.inTime) }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 批次号 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">批次号</text>
|
||||
<text class="line-clamp-1 ml-16rpx text-right" style="max-width: 400rpx;">{{ formatItemBatchNos(item) || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="mt-12rpx flex items-center justify-around border-t border-[#f0f0f0] pt-16rpx">
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#333] font-semibold">{{ item.totalCount || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">总数量</view>
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.totalCount || 0 }}
|
||||
</view>
|
||||
<view class="mt-4rpx text-22rpx text-[#999]">
|
||||
总数量
|
||||
</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#e6a23c] font-semibold">¥{{ item.totalPrice || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">应付</view>
|
||||
<view class="text-30rpx text-[#e6a23c] font-semibold">
|
||||
¥{{ item.totalPrice || 0 }}
|
||||
</view>
|
||||
<view class="mt-4rpx text-22rpx text-[#999]">
|
||||
应付
|
||||
</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#52c41a] font-semibold">¥{{ item.paymentPrice || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">已付</view>
|
||||
<view class="text-30rpx text-[#52c41a] font-semibold">
|
||||
¥{{ item.paymentPrice || 0 }}
|
||||
</view>
|
||||
<view class="mt-4rpx text-22rpx text-[#999]">
|
||||
已付
|
||||
</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view
|
||||
@@ -89,7 +106,9 @@
|
||||
>
|
||||
¥{{ (item.totalPrice || 0) - (item.paymentPrice || 0) }}
|
||||
</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">未付</view>
|
||||
<view class="mt-4rpx text-22rpx text-[#999]">
|
||||
未付
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -107,6 +126,24 @@
|
||||
>
|
||||
修改
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:submit-approval']) && item.status === 10 && !item.hasApprovalRecords"
|
||||
size="small" type="success" plain @click="handleSubmitApproval(item)"
|
||||
>
|
||||
提交审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:query-approval']) && item.hasApprovalRecords"
|
||||
size="small" type="info" plain @click="handleViewApproval(item)"
|
||||
>
|
||||
审批记录
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:approval-record:process']) && item.hasApprovalRecords && item.status !== 20 && item.status !== 30"
|
||||
size="small" type="primary" plain @click="handleProcessApproval(item)"
|
||||
>
|
||||
处理审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleAudit(item)"
|
||||
@@ -120,7 +157,7 @@
|
||||
反审核
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:delete']) && item.status === 10"
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:delete']) && item.status === 10 && !item.hasApprovalRecords"
|
||||
size="small" type="error" plain @click="handleDelete(item.id!)"
|
||||
>
|
||||
删除
|
||||
@@ -151,15 +188,19 @@
|
||||
<!-- 审核弹窗 -->
|
||||
<wd-popup v-model="auditVisible" position="bottom" closable @close="auditVisible = false">
|
||||
<view class="p-32rpx">
|
||||
<view class="text-32rpx text-[#333] font-semibold mb-32rpx text-center">
|
||||
<view class="mb-32rpx text-center text-32rpx text-[#333] font-semibold">
|
||||
采购入库审核
|
||||
</view>
|
||||
<view class="mb-24rpx">
|
||||
<view class="text-26rpx text-[#666] mb-12rpx">是否合格</view>
|
||||
<view class="mb-12rpx text-26rpx text-[#666]">
|
||||
是否合格
|
||||
</view>
|
||||
<wd-switch v-model="auditForm.isQualified" @change="handleQualifiedChange" />
|
||||
</view>
|
||||
<view v-if="!auditForm.isQualified" class="mb-24rpx">
|
||||
<view class="text-26rpx text-[#666] mb-12rpx">返回方式</view>
|
||||
<view class="mb-12rpx text-26rpx text-[#666]">
|
||||
返回方式
|
||||
</view>
|
||||
<wd-radio-group v-model="auditForm.returnType" shape="button">
|
||||
<wd-radio
|
||||
v-for="opt in RETURN_TYPE_OPTIONS"
|
||||
@@ -171,14 +212,16 @@
|
||||
</wd-radio-group>
|
||||
</view>
|
||||
<view v-if="!auditForm.isQualified" class="mb-24rpx">
|
||||
<view class="text-26rpx text-[#666] mb-12rpx">返回备注</view>
|
||||
<view class="mb-12rpx text-26rpx text-[#666]">
|
||||
返回备注
|
||||
</view>
|
||||
<wd-textarea
|
||||
v-model="auditForm.returnRemark"
|
||||
placeholder="请输入返回方式备注"
|
||||
:maxlength="200"
|
||||
/>
|
||||
</view>
|
||||
<view class="flex gap-24rpx mt-32rpx">
|
||||
<view class="mt-32rpx flex gap-24rpx">
|
||||
<wd-button class="flex-1" plain @click="auditVisible = false">
|
||||
取消
|
||||
</wd-button>
|
||||
@@ -188,6 +231,124 @@
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
|
||||
<!-- 提交审批弹窗 -->
|
||||
<wd-popup v-model="submitApprovalVisible" position="bottom" closable @close="submitApprovalVisible = false">
|
||||
<view class="p-32rpx">
|
||||
<view class="mb-32rpx text-center text-32rpx text-[#333] font-semibold">
|
||||
提交审批
|
||||
</view>
|
||||
<view class="mb-24rpx">
|
||||
<view class="mb-12rpx text-26rpx text-[#666]">
|
||||
审批人
|
||||
</view>
|
||||
<wd-input
|
||||
v-model="submitApprovalForm.nextApprover"
|
||||
placeholder="请输入审批人用户名"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-24rpx">
|
||||
<view class="mb-12rpx text-26rpx text-[#666]">
|
||||
备注
|
||||
</view>
|
||||
<wd-textarea
|
||||
v-model="submitApprovalForm.remark"
|
||||
placeholder="请输入备注"
|
||||
:maxlength="200"
|
||||
/>
|
||||
</view>
|
||||
<view class="mt-32rpx flex gap-24rpx">
|
||||
<wd-button class="flex-1" plain @click="submitApprovalVisible = false">
|
||||
取消
|
||||
</wd-button>
|
||||
<wd-button class="flex-1" type="primary" :loading="submitApprovalLoading" @click="confirmSubmitApproval">
|
||||
提交
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
|
||||
<!-- 处理审批弹窗 -->
|
||||
<wd-popup v-model="processApprovalVisible" position="bottom" closable @close="processApprovalVisible = false">
|
||||
<view class="p-32rpx">
|
||||
<view class="mb-32rpx text-center text-32rpx text-[#333] font-semibold">
|
||||
处理审批
|
||||
</view>
|
||||
<view class="mb-24rpx">
|
||||
<view class="mb-12rpx text-26rpx text-[#666]">
|
||||
审批结果
|
||||
</view>
|
||||
<wd-radio-group v-model="processApprovalForm.approvalResult" shape="button">
|
||||
<wd-radio
|
||||
v-for="opt in APPROVAL_RESULT_OPTIONS"
|
||||
:key="opt.value"
|
||||
:value="opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</view>
|
||||
<view class="mb-24rpx">
|
||||
<view class="mb-12rpx text-26rpx text-[#666]">
|
||||
审批意见
|
||||
</view>
|
||||
<wd-textarea
|
||||
v-model="processApprovalForm.comment"
|
||||
placeholder="请输入审批意见"
|
||||
:maxlength="200"
|
||||
/>
|
||||
</view>
|
||||
<view class="mt-32rpx flex gap-24rpx">
|
||||
<wd-button class="flex-1" plain @click="processApprovalVisible = false">
|
||||
取消
|
||||
</wd-button>
|
||||
<wd-button class="flex-1" type="primary" :loading="processApprovalLoading" @click="confirmProcessApproval">
|
||||
确定
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
|
||||
<!-- 审批记录弹窗 -->
|
||||
<wd-popup v-model="approvalRecordsVisible" position="bottom" closable @close="approvalRecordsVisible = false">
|
||||
<view class="p-32rpx">
|
||||
<view class="mb-32rpx text-center text-32rpx text-[#333] font-semibold">
|
||||
审批记录
|
||||
</view>
|
||||
<view v-if="approvalRecords.length === 0" class="py-60rpx text-center text-28rpx text-[#999]">
|
||||
暂无审批记录
|
||||
</view>
|
||||
<view v-else class="max-h-600rpx overflow-y-auto">
|
||||
<view
|
||||
v-for="(record, index) in approvalRecords"
|
||||
:key="record.id || index"
|
||||
class="mb-16rpx rounded-12rpx bg-[#f8f8f8] p-20rpx"
|
||||
>
|
||||
<view class="mb-8rpx flex items-center justify-between">
|
||||
<text class="text-28rpx text-[#333] font-semibold">{{ record.approverName || record.approver }}</text>
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-4rpx text-22rpx"
|
||||
:class="getApprovalResultClass(record.approvalResult)"
|
||||
>
|
||||
{{ getApprovalResultText(record.approvalResult) }}
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="record.comment" class="mb-8rpx text-26rpx text-[#666]">
|
||||
意见:{{ record.comment }}
|
||||
</view>
|
||||
<view class="text-24rpx text-[#999]">
|
||||
{{ record.approvalTime ? new Date(record.approvalTime).toLocaleString('zh-CN') : '-' }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mt-24rpx">
|
||||
<wd-button type="primary" block @click="approvalRecordsVisible = false">
|
||||
关闭
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -197,6 +358,7 @@ import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { APPROVAL_RESULT, APPROVAL_RESULT_OPTIONS, getApprovalRecordListByBiz, processApproval, submitApproval } from '@/api/erp/approval'
|
||||
import { deletePurchaseIn, getPurchaseInPage, RETURN_TYPE_OPTIONS, updatePurchaseInStatus } from '@/api/erp/purchase-in'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
@@ -237,25 +399,96 @@ const auditForm = reactive({
|
||||
returnRemark: undefined as string | undefined,
|
||||
})
|
||||
|
||||
// 提交审批相关
|
||||
const submitApprovalVisible = ref(false)
|
||||
const submitApprovalLoading = ref(false)
|
||||
const submitApprovalForm = reactive({
|
||||
bizId: '' as string,
|
||||
nextApprover: '' as string,
|
||||
remark: '' as string,
|
||||
})
|
||||
|
||||
// 处理审批相关
|
||||
const processApprovalVisible = ref(false)
|
||||
const processApprovalLoading = ref(false)
|
||||
const processApprovalForm = reactive({
|
||||
id: undefined as number | undefined,
|
||||
approvalResult: APPROVAL_RESULT.APPROVED,
|
||||
comment: '' as string,
|
||||
})
|
||||
|
||||
// 审批记录相关
|
||||
const approvalRecordsVisible = ref(false)
|
||||
const approvalRecords = ref<any[]>([])
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(date?: string) {
|
||||
if (!date) return '-'
|
||||
if (!date)
|
||||
return '-'
|
||||
return new Date(date).toLocaleDateString('zh-CN')
|
||||
}
|
||||
|
||||
/** 格式化批次号列表 */
|
||||
function formatItemBatchNos(row: PurchaseIn): string {
|
||||
const items = row?.items || []
|
||||
const batchCountMap = new Map<string, number>()
|
||||
items.forEach((it: any) => {
|
||||
const batchNo = (it?.batchNo || '').trim()
|
||||
if (!batchNo)
|
||||
return
|
||||
const count = Number(it?.count || 0)
|
||||
batchCountMap.set(batchNo, (batchCountMap.get(batchNo) || 0) + count)
|
||||
})
|
||||
if (!batchCountMap.size)
|
||||
return ''
|
||||
return Array.from(batchCountMap.entries())
|
||||
.map(([batchNo, count]) => `${batchNo}[${count}]`)
|
||||
.join(',')
|
||||
}
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number, isQualified?: boolean) {
|
||||
if (status === 10) return '未审核'
|
||||
if (status === 20) return isQualified ? '已审核' : '不合格'
|
||||
if (status === 30) return '不合格'
|
||||
if (status === 10)
|
||||
return '未审核'
|
||||
if (status === 20)
|
||||
return isQualified ? '已审核' : '不合格'
|
||||
if (status === 30)
|
||||
return '不合格'
|
||||
return '未知'
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number, isQualified?: boolean) {
|
||||
if (status === 10) return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
if (status === 20) return isQualified ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff1f0] text-[#f5222d]'
|
||||
if (status === 30) return 'bg-[#fff1f0] text-[#f5222d]'
|
||||
if (status === 10)
|
||||
return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
if (status === 20)
|
||||
return isQualified ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff1f0] text-[#f5222d]'
|
||||
if (status === 30)
|
||||
return 'bg-[#fff1f0] text-[#f5222d]'
|
||||
return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
|
||||
/** 获取审批结果文本 */
|
||||
function getApprovalResultText(result?: number) {
|
||||
if (result === APPROVAL_RESULT.PENDING)
|
||||
return '待审批'
|
||||
if (result === APPROVAL_RESULT.APPROVED)
|
||||
return '已通过'
|
||||
if (result === APPROVAL_RESULT.REJECTED)
|
||||
return '已拒绝'
|
||||
if (result === APPROVAL_RESULT.TRANSFERRED)
|
||||
return '已转办'
|
||||
return '未知'
|
||||
}
|
||||
|
||||
/** 获取审批结果样式 */
|
||||
function getApprovalResultClass(result?: number) {
|
||||
if (result === APPROVAL_RESULT.PENDING)
|
||||
return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
if (result === APPROVAL_RESULT.APPROVED)
|
||||
return 'bg-[#f6ffed] text-[#52c41a]'
|
||||
if (result === APPROVAL_RESULT.REJECTED)
|
||||
return 'bg-[#fff1f0] text-[#f5222d]'
|
||||
return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
|
||||
@@ -270,7 +503,26 @@ async function getList() {
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
const data = await getPurchaseInPage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
|
||||
// 为每条记录检查是否有审批记录
|
||||
const listWithApprovalStatus = await Promise.all(
|
||||
data.list.map(async (item) => {
|
||||
try {
|
||||
const records = await getApprovalRecordListByBiz(String(item.id), 'erp_purchase_in')
|
||||
return {
|
||||
...item,
|
||||
hasApprovalRecords: records && records.length > 0,
|
||||
}
|
||||
} catch {
|
||||
return {
|
||||
...item,
|
||||
hasApprovalRecords: false,
|
||||
}
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
||||
list.value = [...list.value, ...listWithApprovalStatus]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
@@ -364,7 +616,8 @@ function handleQualifiedChange(val: boolean) {
|
||||
|
||||
/** 提交审核 */
|
||||
async function submitAudit() {
|
||||
if (!auditForm.id) return
|
||||
if (!auditForm.id)
|
||||
return
|
||||
if (!auditForm.isQualified && !auditForm.returnType) {
|
||||
toast.warning('请选择返回方式')
|
||||
return
|
||||
@@ -394,7 +647,8 @@ function handleReverseAudit(id: number) {
|
||||
title: '提示',
|
||||
content: '确定反审核该入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
if (!res.confirm)
|
||||
return
|
||||
try {
|
||||
await updatePurchaseInStatus({
|
||||
id,
|
||||
@@ -418,7 +672,8 @@ function handleDelete(id: number) {
|
||||
title: '提示',
|
||||
content: '确定要删除该采购入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
if (!res.confirm)
|
||||
return
|
||||
try {
|
||||
await deletePurchaseIn([id])
|
||||
toast.success('删除成功')
|
||||
@@ -432,6 +687,91 @@ function handleDelete(id: number) {
|
||||
})
|
||||
}
|
||||
|
||||
/** 提交审批 */
|
||||
function handleSubmitApproval(item: PurchaseIn) {
|
||||
submitApprovalForm.bizId = String(item.id)
|
||||
submitApprovalForm.nextApprover = ''
|
||||
submitApprovalForm.remark = ''
|
||||
submitApprovalVisible.value = true
|
||||
}
|
||||
|
||||
/** 确认提交审批 */
|
||||
async function confirmSubmitApproval() {
|
||||
if (!submitApprovalForm.nextApprover) {
|
||||
toast.warning('请输入审批人')
|
||||
return
|
||||
}
|
||||
submitApprovalLoading.value = true
|
||||
try {
|
||||
await submitApproval({
|
||||
bizId: submitApprovalForm.bizId,
|
||||
bizTableName: 'erp_purchase_in',
|
||||
nextApprover: submitApprovalForm.nextApprover,
|
||||
remark: submitApprovalForm.remark,
|
||||
})
|
||||
toast.success('提交审批成功')
|
||||
submitApprovalVisible.value = false
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} finally {
|
||||
submitApprovalLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 查看审批记录 */
|
||||
async function handleViewApproval(item: PurchaseIn) {
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
const records = await getApprovalRecordListByBiz(String(item.id), 'erp_purchase_in')
|
||||
approvalRecords.value = records || []
|
||||
approvalRecordsVisible.value = true
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 处理审批 */
|
||||
async function handleProcessApproval(item: PurchaseIn) {
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
const records = await getApprovalRecordListByBiz(String(item.id), 'erp_purchase_in')
|
||||
// 找到待处理的审批记录
|
||||
const pendingRecord = records?.find((r: any) => r.approvalResult === APPROVAL_RESULT.PENDING)
|
||||
if (!pendingRecord) {
|
||||
toast.warning('没有待处理的审批记录')
|
||||
return
|
||||
}
|
||||
processApprovalForm.id = pendingRecord.id
|
||||
processApprovalForm.approvalResult = APPROVAL_RESULT.APPROVED
|
||||
processApprovalForm.comment = ''
|
||||
processApprovalVisible.value = true
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 确认处理审批 */
|
||||
async function confirmProcessApproval() {
|
||||
if (!processApprovalForm.id)
|
||||
return
|
||||
processApprovalLoading.value = true
|
||||
try {
|
||||
await processApproval({
|
||||
id: processApprovalForm.id,
|
||||
approvalResult: processApprovalForm.approvalResult,
|
||||
comment: processApprovalForm.comment,
|
||||
})
|
||||
toast.success('审批处理成功')
|
||||
processApprovalVisible.value = false
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} finally {
|
||||
processApprovalLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
|
||||
Reference in New Issue
Block a user