fix: 李红攀:V2.0.008采购入库库位推荐的同步

This commit is contained in:
2026-05-23 16:42:27 +08:00
parent 5f9b83dbda
commit 2169fec9c1
10 changed files with 802 additions and 165 deletions

6
env/.env vendored
View File

@@ -1,7 +1,7 @@
VITE_APP_TITLE = '亚为mom小程序' VITE_APP_TITLE = '亚为mom小程序'
VITE_APP_PORT = 9000 VITE_APP_PORT = 9000
VITE_UNI_APPID = '__UNI__7CADA36' VITE_UNI_APPID = '__UNI__2EB12DE'
VITE_WX_APPID = 'wx1a832d51073d3a35' VITE_WX_APPID = 'wx1a832d51073d3a35'
# h5部署网站的base配置到 manifest.config.ts 里的 h5.router.base # h5部署网站的base配置到 manifest.config.ts 里的 h5.router.base
@@ -10,8 +10,8 @@ VITE_WX_APPID = 'wx1a832d51073d3a35'
VITE_APP_PUBLIC_BASE=/ VITE_APP_PUBLIC_BASE=/
# 后台请求地址 # 后台请求地址
VITE_SERVER_BASEURL = 'http://192.168.1.20:48080/admin-api' VITE_SERVER_BASEURL = 'http://127.0.0.1:48080/admin-api'
VITE_UPLOAD_BASEURL = 'http://192.168.1.20:48080/upload' VITE_UPLOAD_BASEURL = 'http://127.0.0.1:48080/upload'
# 备注如果后台带统一前缀则也要加到后面eg: https://ukw0y1.laf.run/api # 备注如果后台带统一前缀则也要加到后面eg: https://ukw0y1.laf.run/api
# 注意,如果是微信小程序,还有一套请求地址的配置,根据 develop、trial、release 分别设置上传地址,见 `src/utils/index.ts`。 # 注意,如果是微信小程序,还有一套请求地址的配置,根据 develop、trial、release 分别设置上传地址,见 `src/utils/index.ts`。

View File

@@ -82,33 +82,33 @@ export default defineManifestConfig({
/* 图标配置 */ /* 图标配置 */
icons: { icons: {
android: { android: {
hdpi: 'static/app/icons/72x72.png', hdpi: 'src/static/app/icons/72x72.png',
xhdpi: 'static/app/icons/96x96.png', xhdpi: 'src/static/app/icons/96x96.png',
xxhdpi: 'static/app/icons/144x144.png', xxhdpi: 'src/static/app/icons/144x144.png',
xxxhdpi: 'static/app/icons/192x192.png', xxxhdpi: 'src/static/app/icons/192x192.png',
}, },
ios: { ios: {
appstore: 'static/app/icons/1024x1024.png', appstore: 'src/static/app/icons/1024x1024.png',
ipad: { ipad: {
'app': 'static/app/icons/76x76.png', 'app': 'src/static/app/icons/76x76.png',
'app@2x': 'static/app/icons/152x152.png', 'app@2x': 'src/static/app/icons/152x152.png',
'notification': 'static/app/icons/20x20.png', 'notification': 'src/static/app/icons/20x20.png',
'notification@2x': 'static/app/icons/40x40.png', 'notification@2x': 'src/static/app/icons/40x40.png',
'proapp@2x': 'static/app/icons/167x167.png', 'proapp@2x': 'src/static/app/icons/167x167.png',
'settings': 'static/app/icons/29x29.png', 'settings': 'src/static/app/icons/29x29.png',
'settings@2x': 'static/app/icons/58x58.png', 'settings@2x': 'src/static/app/icons/58x58.png',
'spotlight': 'static/app/icons/40x40.png', 'spotlight': 'src/static/app/icons/40x40.png',
'spotlight@2x': 'static/app/icons/80x80.png', 'spotlight@2x': 'src/static/app/icons/80x80.png',
}, },
iphone: { iphone: {
'app@2x': 'static/app/icons/120x120.png', 'app@2x': 'src/static/app/icons/120x120.png',
'app@3x': 'static/app/icons/180x180.png', 'app@3x': 'src/static/app/icons/180x180.png',
'notification@2x': 'static/app/icons/40x40.png', 'notification@2x': 'src/static/app/icons/40x40.png',
'notification@3x': 'static/app/icons/60x60.png', 'notification@3x': 'src/static/app/icons/60x60.png',
'settings@2x': 'static/app/icons/58x58.png', 'settings@2x': 'src/static/app/icons/58x58.png',
'settings@3x': 'static/app/icons/87x87.png', 'settings@3x': 'src/static/app/icons/87x87.png',
'spotlight@2x': 'static/app/icons/80x80.png', 'spotlight@2x': 'src/static/app/icons/80x80.png',
'spotlight@3x': 'static/app/icons/120x120.png', 'spotlight@3x': 'src/static/app/icons/120x120.png',
}, },
}, },
}, },

View File

@@ -93,7 +93,6 @@
"init-husky": "git init && husky", "init-husky": "git init && husky",
"init-baseFiles": "node ./scripts/create-base-files.js", "init-baseFiles": "node ./scripts/create-base-files.js",
"init-json": "pnpm init-baseFiles", "init-json": "pnpm init-baseFiles",
"prepare": "pnpm init-husky & pnpm init-baseFiles",
"lint": "eslint", "lint": "eslint",
"lint:fix": "eslint --fix" "lint:fix": "eslint --fix"
}, },
@@ -180,9 +179,6 @@
"pnpm": { "pnpm": {
"overrides": { "overrides": {
"unconfig": "7.3.2" "unconfig": "7.3.2"
},
"patchedDependencies": {
"wot-design-uni@1.13.0": "patches/wot-design-uni@1.13.0.patch"
} }
}, },
"overrides": { "overrides": {

9
pnpm-lock.yaml generated
View File

@@ -8,11 +8,6 @@ overrides:
bin-wrapper: npm:bin-wrapper-china bin-wrapper: npm:bin-wrapper-china
unconfig: 7.3.2 unconfig: 7.3.2
patchedDependencies:
wot-design-uni@1.13.0:
hash: 29ab7840a74d54969d4cbe5b840208d3d4911a82be189ac8581d462190fb5210
path: patches/wot-design-uni@1.13.0.patch
importers: importers:
.: .:
@@ -94,7 +89,7 @@ importers:
version: 4.5.1(vue@3.4.21(typescript@5.8.3)) version: 4.5.1(vue@3.4.21(typescript@5.8.3))
wot-design-uni: wot-design-uni:
specifier: ^1.13.0 specifier: ^1.13.0
version: 1.13.0(patch_hash=29ab7840a74d54969d4cbe5b840208d3d4911a82be189ac8581d462190fb5210)(vue@3.4.21(typescript@5.8.3)) version: 1.13.0(vue@3.4.21(typescript@5.8.3))
z-paging: z-paging:
specifier: 2.8.7 specifier: 2.8.7
version: 2.8.7 version: 2.8.7
@@ -13321,7 +13316,7 @@ snapshots:
word-wrap@1.2.5: {} word-wrap@1.2.5: {}
wot-design-uni@1.13.0(patch_hash=29ab7840a74d54969d4cbe5b840208d3d4911a82be189ac8581d462190fb5210)(vue@3.4.21(typescript@5.8.3)): wot-design-uni@1.13.0(vue@3.4.21(typescript@5.8.3)):
dependencies: dependencies:
vue: 3.4.21(typescript@5.8.3) vue: 3.4.21(typescript@5.8.3)

View File

@@ -0,0 +1,82 @@
import { http } from '@/http/http'
/** 审批记录 */
export interface ApprovalRecord {
id?: number
processInstanceId: string
bizId: string
bizTableName: string
applicant: string
applicantName?: string
approver: string
approverName?: string
assigner?: string
assignerName?: string
assignReason?: string
approvalTime?: string
comment?: string
approvalResult: number
flowType: number
parentApprovalId?: number
approvalLevel: number
processStatus: number
sort?: number
createTime?: string
updateTime?: string
}
/** 提交审批参数 */
export interface ApprovalSubmitVO {
bizId: string
bizTableName: string
nextApprover: string
remark?: string
}
/** 处理审批参数 */
export interface ApprovalProcessVO {
id: number
approvalResult: number
comment?: string
nextApprover?: string
assignReason?: string
}
/** 审批结果枚举 */
export const APPROVAL_RESULT = {
PENDING: 0, // 待审批
APPROVED: 1, // 通过
REJECTED: 2, // 拒绝
TRANSFERRED: 3, // 转办
}
/** 审批结果选项 */
export const APPROVAL_RESULT_OPTIONS = [
{ label: '通过', value: APPROVAL_RESULT.APPROVED },
{ label: '拒绝', value: APPROVAL_RESULT.REJECTED },
]
/** 提交审批 */
export function submitApproval(data: ApprovalSubmitVO) {
return http.post<number>('/erp/approval-record/submit', data)
}
/** 处理审批 */
export function processApproval(data: ApprovalProcessVO) {
return http.post<boolean>('/erp/approval-record/process', data)
}
/** 获取业务单据的审批记录列表 */
export function getApprovalRecordListByBiz(bizId: string, bizTableName: string) {
return http.get<ApprovalRecord[]>('/erp/approval-record/list-by-biz', { bizId, bizTableName })
}
/** 获取用户的待办审批列表 */
export function getPendingApprovalList(approver: string) {
return http.get<ApprovalRecord[]>('/erp/approval-record/pending-list', { approver })
}
/** 终止审批流程 */
export function terminateApproval(bizId: string, bizTableName: string) {
return http.post<boolean>('/erp/approval-record/terminate', { bizId, bizTableName })
}

View File

@@ -22,6 +22,7 @@ export interface PurchaseInItem {
productCategoryName?: string productCategoryName?: string
stockCount?: number stockCount?: number
totalCount?: number totalCount?: number
inCount?: number
totalPrice?: number totalPrice?: number
totalProductPrice?: number totalProductPrice?: number
orderItemId?: number orderItemId?: number
@@ -57,6 +58,7 @@ export interface PurchaseIn {
isQualified?: boolean isQualified?: boolean
returnType?: string | null returnType?: string | null
returnRemark?: string returnRemark?: string
hasApprovalRecords?: boolean
} }
/** 审核表单数据 */ /** 审核表单数据 */

View File

@@ -74,9 +74,17 @@
<text class="text-28rpx text-[#333] font-semibold">{{ item.productName || '-' }}</text> <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> <text v-if="item.productBarCode" class="ml-12rpx text-22rpx text-[#999]">{{ item.productBarCode }}</text>
</view> </view>
<view class="flex items-center">
<text v-if="item.warehouseName" class="text-24rpx text-[#1890ff]">{{ item.warehouseName }}</text> <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>
<view class="p-24rpx"> <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]"> <view v-if="item.productSpec" class="mb-12rpx flex items-center text-26rpx text-[#666]">
<text class="mr-8rpx text-[#999]">规格</text> <text class="mr-8rpx text-[#999]">规格</text>
@@ -170,15 +178,19 @@
<!-- 审核弹窗 --> <!-- 审核弹窗 -->
<wd-popup v-model="auditVisible" position="bottom" closable @close="auditVisible = false"> <wd-popup v-model="auditVisible" position="bottom" closable @close="auditVisible = false">
<view class="p-32rpx"> <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>
<view class="mb-24rpx"> <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" /> <wd-switch v-model="auditForm.isQualified" @change="handleQualifiedChange" />
</view> </view>
<view v-if="!auditForm.isQualified" class="mb-24rpx"> <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-group v-model="auditForm.returnType" shape="button">
<wd-radio <wd-radio
v-for="opt in RETURN_TYPE_OPTIONS" v-for="opt in RETURN_TYPE_OPTIONS"
@@ -190,14 +202,16 @@
</wd-radio-group> </wd-radio-group>
</view> </view>
<view v-if="!auditForm.isQualified" class="mb-24rpx"> <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 <wd-textarea
v-model="auditForm.returnRemark" v-model="auditForm.returnRemark"
placeholder="请输入返回方式备注" placeholder="请输入返回方式备注"
:maxlength="200" :maxlength="200"
/> />
</view> </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 class="flex-1" plain @click="auditVisible = false">
取消 取消
</wd-button> </wd-button>
@@ -246,23 +260,30 @@ const auditForm = reactive({
/** 获取状态文本 */ /** 获取状态文本 */
function getStatusText(status?: number, isQualified?: boolean) { function getStatusText(status?: number, isQualified?: boolean) {
if (status === 10) return '未审核' if (status === 10)
if (status === 20) return isQualified ? '审核' : '不合格' return '审核'
if (status === 30) return '不合格' if (status === 20)
return isQualified ? '已审核' : '不合格'
if (status === 30)
return '不合格'
return '未知' return '未知'
} }
/** 获取状态样式 */ /** 获取状态样式 */
function getStatusClass(status?: number, isQualified?: boolean) { function getStatusClass(status?: number, isQualified?: boolean) {
if (status === 10) return 'bg-[#fff7e6] text-[#fa8c16]' if (status === 10)
if (status === 20) return isQualified ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff1f0] text-[#f5222d]' return 'bg-[#fff7e6] text-[#fa8c16]'
if (status === 30) return 'bg-[#fff1f0] text-[#f5222d]' 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]' return 'bg-[#f5f5f5] text-[#999]'
} }
/** 获取返回方式标签 */ /** 获取返回方式标签 */
function getReturnTypeLabel(value?: string | null) { function getReturnTypeLabel(value?: string | null) {
if (!value) return '-' if (!value)
return '-'
const option = RETURN_TYPE_OPTIONS.find(opt => opt.value === value) const option = RETURN_TYPE_OPTIONS.find(opt => opt.value === value)
return option ? option.label : value return option ? option.label : value
} }
@@ -310,7 +331,8 @@ function handleQualifiedChange(val: boolean) {
/** 提交审核 */ /** 提交审核 */
async function submitAudit() { async function submitAudit() {
if (!props.id) return if (!props.id)
return
if (!auditForm.isQualified && !auditForm.returnType) { if (!auditForm.isQualified && !auditForm.returnType) {
toast.warning('请选择返回方式') toast.warning('请选择返回方式')
return return

View File

@@ -26,7 +26,7 @@
placeholder="请选择入库时间" placeholder="请选择入库时间"
/> />
</wd-cell> </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-if="formData.orderNo" class="text-[#1890ff]">{{ formData.orderNo }}</text>
<text v-else class="text-[#999]">点击选择采购订单</text> <text v-else class="text-[#999]">点击选择采购订单</text>
</wd-cell> </wd-cell>
@@ -97,6 +97,18 @@
> >
<view class="flex items-center justify-between bg-[#f8f8f8] px-24rpx py-12rpx"> <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> <text class="text-28rpx text-[#333] font-semibold">产品 #{{ index + 1 }} {{ item.productName || '' }}</text>
<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 <wd-button
v-if="formData.items && formData.items.length > 1" v-if="formData.items && formData.items.length > 1"
size="small" type="error" plain @click="handleRemoveItem(index)" size="small" type="error" plain @click="handleRemoveItem(index)"
@@ -104,6 +116,7 @@
删除 删除
</wd-button> </wd-button>
</view> </view>
</view>
<view class="p-24rpx"> <view class="p-24rpx">
<!-- 仓库选择 --> <!-- 仓库选择 -->
<view class="mb-16rpx"> <view class="mb-16rpx">
@@ -115,6 +128,24 @@
@confirm="(e: any) => onWarehouseConfirm(e, index)" @confirm="(e: any) => onWarehouseConfirm(e, index)"
/> />
</view> </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 v-if="item.productId" class="mb-16rpx rounded-8rpx bg-[#f9f9f9] p-16rpx">
<view class="mb-8rpx flex justify-between text-24rpx"> <view class="mb-8rpx flex justify-between text-24rpx">
@@ -232,7 +263,9 @@
> >
<view class="p-24rpx"> <view class="p-24rpx">
<view class="mb-12rpx flex items-center justify-between"> <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" /> <wd-icon v-if="selectedOrderId === item.id" name="check" color="#1890ff" size="40rpx" />
</view> </view>
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]"> <view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
@@ -241,20 +274,32 @@
</view> </view>
<view class="mb-8rpx 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 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>
<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-center">
<view class="text-28rpx text-[#333] font-semibold">{{ item.totalCount || 0 }}</view> <view class="text-28rpx text-[#333] font-semibold">
<view class="text-22rpx text-[#999]">总数量</view> {{ item.totalCount || 0 }}
</view>
<view class="text-22rpx text-[#999]">
总数量
</view>
</view> </view>
<view class="text-center"> <view class="text-center">
<view class="text-28rpx text-[#52c41a] font-semibold">{{ item.inCount || 0 }}</view> <view class="text-28rpx text-[#52c41a] font-semibold">
<view class="text-22rpx text-[#999]">已入库</view> {{ item.inCount || 0 }}
</view>
<view class="text-22rpx text-[#999]">
已入库
</view>
</view> </view>
<view class="text-center"> <view class="text-center">
<view class="text-28rpx text-[#e6a23c] font-semibold">¥{{ item.totalPrice || 0 }}</view> <view class="text-28rpx text-[#e6a23c] font-semibold">
<view class="text-22rpx text-[#999]">含税金额</view> ¥{{ item.totalPrice || 0 }}
</view>
<view class="text-22rpx text-[#999]">
含税金额
</view>
</view> </view>
</view> </view>
</view> </view>
@@ -301,6 +346,9 @@ interface WarehouseSimple {
id: number id: number
name: string name: string
defaultStatus?: boolean 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 })), 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() { function getSupplierName() {
if (!formData.value.supplierId) return '' if (!formData.value.supplierId)
return ''
const supplier = supplierList.value.find(s => s.id === formData.value.supplierId) const supplier = supplierList.value.find(s => s.id === formData.value.supplierId)
return supplier?.name || formData.value.supplierName || '' 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]) { if (formData.value.items && formData.value.items[index]) {
formData.value.items[index].warehouseId = value?.[0] // wd-picker 的 confirm 事件返回 { value, selectedItems }
const warehouse = warehouseList.value.find(w => w.id === value?.[0]) 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) { if (warehouse) {
formData.value.items[index].warehouseName = warehouse.name 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( watch(
() => formData.value, () => formData.value,
(val) => { (val) => {
if (!val || !val.items) return if (!val || !val.items)
return
// 计算每个明细的金额 // 计算每个明细的金额
val.items.forEach((item) => { val.items.forEach((item) => {
if (item.productPrice && item.count) { if (item.productPrice && item.count) {
@@ -437,6 +505,7 @@ async function loadDropdownData() {
supplierList.value = suppliers || [] supplierList.value = suppliers || []
accountList.value = accounts || [] accountList.value = accounts || []
warehouseList.value = warehouses || [] warehouseList.value = warehouses || []
console.log('[仓库数据] warehouseList:', warehouseList.value)
// 设置默认账户 // 设置默认账户
const defaultAccount = accountList.value.find(a => a.defaultStatus) const defaultAccount = accountList.value.find(a => a.defaultStatus)
if (defaultAccount && !formData.value.accountId) { 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() { function openOrderSelect() {
orderSelectVisible.value = true orderSelectVisible.value = true
@@ -495,7 +693,8 @@ async function getOrderList() {
/** 加载更多订单 */ /** 加载更多订单 */
function loadMoreOrders() { function loadMoreOrders() {
if (orderLoadMoreState.value === 'finished') return if (orderLoadMoreState.value === 'finished')
return
orderQueryParams.value.pageNo++ orderQueryParams.value.pageNo++
getOrderList() getOrderList()
} }
@@ -507,7 +706,8 @@ function handleSelectOrder(item: PurchaseOrder) {
/** 确认选择订单 */ /** 确认选择订单 */
async function confirmSelectOrder() { async function confirmSelectOrder() {
if (!selectedOrderId.value) return if (!selectedOrderId.value)
return
try { try {
toast.loading('加载订单详情...') toast.loading('加载订单详情...')
const orderDetail = await getPurchaseOrder(selectedOrderId.value) const orderDetail = await getPurchaseOrder(selectedOrderId.value)

View File

@@ -11,18 +11,18 @@
<SearchForm @search="handleQuery" @reset="handleReset" /> <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 <view
v-for="tab in statusTabs" v-for="tab in statusTabs"
:key="tab.value" :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]'" :class="activeStatus === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'"
@click="handleQuickFilter(tab.value)" @click="handleQuickFilter(tab.value)"
> >
{{ tab.label }} {{ tab.label }}
<view <view
v-if="activeStatus === tab.value" 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>
</view> </view>
@@ -56,7 +56,7 @@
<!-- 产品 --> <!-- 产品 -->
<view class="mb-8rpx 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 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>
<!-- 入库时间 --> <!-- 入库时间 -->
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]"> <view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
@@ -64,23 +64,40 @@
<text>{{ formatDate(item.inTime) }}</text> <text>{{ formatDate(item.inTime) }}</text>
</view> </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 class="text-[#999]">创建人</text>
<text>{{ item.creatorName || '-' }}</text> <text>{{ item.creatorName || '-' }}</text>
</view> </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-center">
<view class="text-30rpx text-[#333] font-semibold">{{ item.totalCount || 0 }}</view> <view class="text-30rpx text-[#333] font-semibold">
<view class="text-22rpx text-[#999] mt-4rpx">总数量</view> {{ item.totalCount || 0 }}
</view>
<view class="mt-4rpx text-22rpx text-[#999]">
总数量
</view>
</view> </view>
<view class="text-center"> <view class="text-center">
<view class="text-30rpx text-[#e6a23c] font-semibold">¥{{ item.totalPrice || 0 }}</view> <view class="text-30rpx text-[#e6a23c] font-semibold">
<view class="text-22rpx text-[#999] mt-4rpx">应付</view> ¥{{ item.totalPrice || 0 }}
</view>
<view class="mt-4rpx text-22rpx text-[#999]">
应付
</view>
</view> </view>
<view class="text-center"> <view class="text-center">
<view class="text-30rpx text-[#52c41a] font-semibold">¥{{ item.paymentPrice || 0 }}</view> <view class="text-30rpx text-[#52c41a] font-semibold">
<view class="text-22rpx text-[#999] mt-4rpx">已付</view> ¥{{ item.paymentPrice || 0 }}
</view>
<view class="mt-4rpx text-22rpx text-[#999]">
已付
</view>
</view> </view>
<view class="text-center"> <view class="text-center">
<view <view
@@ -89,7 +106,9 @@
> >
¥{{ (item.totalPrice || 0) - (item.paymentPrice || 0) }} ¥{{ (item.totalPrice || 0) - (item.paymentPrice || 0) }}
</view> </view>
<view class="text-22rpx text-[#999] mt-4rpx">未付</view> <view class="mt-4rpx text-22rpx text-[#999]">
未付
</view>
</view> </view>
</view> </view>
</view> </view>
@@ -107,6 +126,24 @@
> >
修改 修改
</wd-button> </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 <wd-button
v-if="hasAccessByCodes(['erp:purchase-in:update-status']) && item.status === 10" v-if="hasAccessByCodes(['erp:purchase-in:update-status']) && item.status === 10"
size="small" type="success" plain @click="handleAudit(item)" size="small" type="success" plain @click="handleAudit(item)"
@@ -120,7 +157,7 @@
反审核 反审核
</wd-button> </wd-button>
<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!)" size="small" type="error" plain @click="handleDelete(item.id!)"
> >
删除 删除
@@ -151,15 +188,19 @@
<!-- 审核弹窗 --> <!-- 审核弹窗 -->
<wd-popup v-model="auditVisible" position="bottom" closable @close="auditVisible = false"> <wd-popup v-model="auditVisible" position="bottom" closable @close="auditVisible = false">
<view class="p-32rpx"> <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>
<view class="mb-24rpx"> <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" /> <wd-switch v-model="auditForm.isQualified" @change="handleQualifiedChange" />
</view> </view>
<view v-if="!auditForm.isQualified" class="mb-24rpx"> <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-group v-model="auditForm.returnType" shape="button">
<wd-radio <wd-radio
v-for="opt in RETURN_TYPE_OPTIONS" v-for="opt in RETURN_TYPE_OPTIONS"
@@ -171,14 +212,16 @@
</wd-radio-group> </wd-radio-group>
</view> </view>
<view v-if="!auditForm.isQualified" class="mb-24rpx"> <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 <wd-textarea
v-model="auditForm.returnRemark" v-model="auditForm.returnRemark"
placeholder="请输入返回方式备注" placeholder="请输入返回方式备注"
:maxlength="200" :maxlength="200"
/> />
</view> </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 class="flex-1" plain @click="auditVisible = false">
取消 取消
</wd-button> </wd-button>
@@ -188,6 +231,124 @@
</view> </view>
</view> </view>
</wd-popup> </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> </view>
</template> </template>
@@ -197,6 +358,7 @@ import type { LoadMoreState } from '@/http/types'
import { onReachBottom } from '@dcloudio/uni-app' import { onReachBottom } from '@dcloudio/uni-app'
import { onMounted, reactive, ref } from 'vue' import { onMounted, reactive, ref } from 'vue'
import { useToast } from 'wot-design-uni' 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 { deletePurchaseIn, getPurchaseInPage, RETURN_TYPE_OPTIONS, updatePurchaseInStatus } from '@/api/erp/purchase-in'
import { useAccess } from '@/hooks/useAccess' import { useAccess } from '@/hooks/useAccess'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
@@ -237,25 +399,96 @@ const auditForm = reactive({
returnRemark: undefined as string | undefined, 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) { function formatDate(date?: string) {
if (!date) return '-' if (!date)
return '-'
return new Date(date).toLocaleDateString('zh-CN') 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) { function getStatusText(status?: number, isQualified?: boolean) {
if (status === 10) return '未审核' if (status === 10)
if (status === 20) return isQualified ? '审核' : '不合格' return '审核'
if (status === 30) return '不合格' if (status === 20)
return isQualified ? '已审核' : '不合格'
if (status === 30)
return '不合格'
return '未知' return '未知'
} }
/** 获取状态样式 */ /** 获取状态样式 */
function getStatusClass(status?: number, isQualified?: boolean) { function getStatusClass(status?: number, isQualified?: boolean) {
if (status === 10) return 'bg-[#fff7e6] text-[#fa8c16]' if (status === 10)
if (status === 20) return isQualified ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff1f0] text-[#f5222d]' return 'bg-[#fff7e6] text-[#fa8c16]'
if (status === 30) return 'bg-[#fff1f0] text-[#f5222d]' 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]' return 'bg-[#f5f5f5] text-[#999]'
} }
@@ -270,7 +503,26 @@ async function getList() {
try { try {
const params = { ...queryParams.value } const params = { ...queryParams.value }
const data = await getPurchaseInPage(params) 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 total.value = data.total
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading' loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
} catch { } catch {
@@ -364,7 +616,8 @@ function handleQualifiedChange(val: boolean) {
/** 提交审核 */ /** 提交审核 */
async function submitAudit() { async function submitAudit() {
if (!auditForm.id) return if (!auditForm.id)
return
if (!auditForm.isQualified && !auditForm.returnType) { if (!auditForm.isQualified && !auditForm.returnType) {
toast.warning('请选择返回方式') toast.warning('请选择返回方式')
return return
@@ -394,7 +647,8 @@ function handleReverseAudit(id: number) {
title: '提示', title: '提示',
content: '确定反审核该入库单吗?', content: '确定反审核该入库单吗?',
success: async (res) => { success: async (res) => {
if (!res.confirm) return if (!res.confirm)
return
try { try {
await updatePurchaseInStatus({ await updatePurchaseInStatus({
id, id,
@@ -418,7 +672,8 @@ function handleDelete(id: number) {
title: '提示', title: '提示',
content: '确定要删除该采购入库单吗?', content: '确定要删除该采购入库单吗?',
success: async (res) => { success: async (res) => {
if (!res.confirm) return if (!res.confirm)
return
try { try {
await deletePurchaseIn([id]) await deletePurchaseIn([id])
toast.success('删除成功') 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(() => { onReachBottom(() => {
loadMore() loadMore()

View File

@@ -26,68 +26,68 @@ export interface MenuGroup {
/** 菜单分组原始数据 */ /** 菜单分组原始数据 */
const menuGroupsData: MenuGroup[] = [ const menuGroupsData: MenuGroup[] = [
// { {
// key: 'purchase', key: 'purchase',
// name: '采购管理', name: '采购管理',
// menus: [ menus: [
// { {
// key: 'purchaseRequisition', key: 'purchaseRequisition',
// name: '采购申请', name: '采购申请',
// icon: 'edit', icon: 'edit',
// url: '/pages-erp/purchase-requisition/index', url: '/pages-erp/purchase-requisition/index',
// iconColor: '#2f54eb', iconColor: '#2f54eb',
// permission: 'erp:purchase-requisition:query', permission: 'erp:purchase-requisition:query',
// }, },
// { {
// key: 'purchaseOrder', key: 'purchaseOrder',
// name: '采购订单', name: '采购订单',
// icon: 'order', icon: 'order',
// url: '/pages-erp/purchase-order/index', url: '/pages-erp/purchase-order/index',
// iconColor: '#1890ff', iconColor: '#1890ff',
// permission: 'erp:purchase-order:query', permission: 'erp:purchase-order:query',
// }, },
// { {
// key: 'purchaseIn', key: 'purchaseIn',
// name: '采购入库', name: '采购入库',
// icon: 'goods', icon: 'goods',
// url: '/pages-erp/purchase-in/index', url: '/pages-erp/purchase-in/index',
// iconColor: '#52c41a', iconColor: '#52c41a',
// permission: 'erp:purchase-in:query', permission: 'erp:purchase-in:query',
// }, },
// { {
// key: 'purchaseReturn', key: 'purchaseReturn',
// name: '采购退货', name: '采购退货',
// icon: 'refund', icon: 'refund',
// url: '/pages-erp/purchase-return/index', url: '/pages-erp/purchase-return/index',
// iconColor: '#fa8c16', iconColor: '#fa8c16',
// permission: 'erp:purchase-return:query', permission: 'erp:purchase-return:query',
// }, },
// { {
// key: 'supplier', key: 'supplier',
// name: '供应商', name: '供应商',
// icon: 'shop', icon: 'shop',
// url: '/pages-erp/supplier/index', url: '/pages-erp/supplier/index',
// iconColor: '#722ed1', iconColor: '#722ed1',
// permission: 'erp:supplier:query', permission: 'erp:supplier:query',
// }, },
// { {
// key: 'farmer', key: 'farmer',
// name: '农户管理', name: '农户管理',
// icon: 'user', icon: 'user',
// url: '/pages-erp/farmer/index', url: '/pages-erp/farmer/index',
// iconColor: '#13c2c2', iconColor: '#13c2c2',
// permission: 'erp:farmer:query', permission: 'erp:farmer:query',
// }, },
// { {
// key: 'pickBroccoli', key: 'pickBroccoli',
// name: '采摘管理', name: '采摘管理',
// icon: 'flower', icon: 'flower',
// url: '/pages-erp/pick-broccoli/index', url: '/pages-erp/pick-broccoli/index',
// iconColor: '#eb2f96', iconColor: '#eb2f96',
// permission: 'erp:pick-broccoli:query', permission: 'erp:pick-broccoli:query',
// }, },
// ], ],
// }, },
// { // {
// key: 'agri', // key: 'agri',
// name: '农业溯源', // name: '农业溯源',