Compare commits
5 Commits
master
...
dev-common
| Author | SHA1 | Date | |
|---|---|---|---|
| 66f47cdde4 | |||
| 6f1f32df62 | |||
| 505fda77f0 | |||
| 5586e8e39a | |||
| 45eb9232d7 |
6
env/.env
vendored
6
env/.env
vendored
@@ -1,4 +1,4 @@
|
||||
VITE_APP_TITLE = '芋道管理系统'
|
||||
VITE_APP_TITLE = '亚为mom小程序'
|
||||
VITE_APP_PORT = 9000
|
||||
|
||||
VITE_UNI_APPID = '__UNI__D1E5001'
|
||||
@@ -39,8 +39,8 @@ VITE_APP_TENANT_ENABLE=true
|
||||
VITE_APP_CAPTCHA_ENABLE=false
|
||||
# 默认账户密码
|
||||
VITE_APP_DEFAULT_LOGIN_TENANT_ID = 1
|
||||
VITE_APP_DEFAULT_LOGIN_USERNAME = admin
|
||||
VITE_APP_DEFAULT_LOGIN_PASSWORD = admin123
|
||||
VITE_APP_DEFAULT_LOGIN_USERNAME = YAVII
|
||||
VITE_APP_DEFAULT_LOGIN_PASSWORD = yavii123
|
||||
|
||||
# API 加解密
|
||||
VITE_APP_API_ENCRYPT_ENABLE = true
|
||||
|
||||
74
src/api/agri/biz/flow.ts
Normal file
74
src/api/agri/biz/flow.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import { http } from '@/http/http'
|
||||
|
||||
export interface AgriHarvestSubmitReqVO {
|
||||
batchType: string
|
||||
productId?: number
|
||||
productName?: string
|
||||
plotId?: number
|
||||
plotName?: string
|
||||
farmerId?: number
|
||||
quantity?: number
|
||||
unit?: string
|
||||
harvestTime?: string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export interface AgriSortingSubmitReqVO {
|
||||
batchId: number
|
||||
weightResult?: number
|
||||
unqualifiedCategory?: string
|
||||
imageUrl?: string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export interface AgriPackingSubmitReqVO {
|
||||
batchId: number
|
||||
netWeight?: number
|
||||
labelCode?: string
|
||||
packingTime?: string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export interface AgriWarehouseInReqVO {
|
||||
batchId: number
|
||||
inMode?: string
|
||||
warehouseTime?: string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export interface AgriShipmentDispatchReqVO {
|
||||
batchId: number
|
||||
vehicleNo: string
|
||||
boxCount?: number
|
||||
shipmentTime?: string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export interface AgriShipmentSignReqVO {
|
||||
batchId: number
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export function submitHarvest(data: AgriHarvestSubmitReqVO) {
|
||||
return http.post<number>('/agri/biz/flow/harvest', data)
|
||||
}
|
||||
|
||||
export function submitSorting(data: AgriSortingSubmitReqVO) {
|
||||
return http.post<void>('/agri/biz/flow/sorting', data)
|
||||
}
|
||||
|
||||
export function submitPacking(data: AgriPackingSubmitReqVO) {
|
||||
return http.post<void>('/agri/biz/flow/packing', data)
|
||||
}
|
||||
|
||||
export function submitWarehouseIn(data: AgriWarehouseInReqVO) {
|
||||
return http.post<void>('/agri/biz/flow/warehouse-in', data)
|
||||
}
|
||||
|
||||
export function dispatchShipment(data: AgriShipmentDispatchReqVO) {
|
||||
return http.post<void>('/agri/biz/flow/shipment-dispatch', data)
|
||||
}
|
||||
|
||||
export function signShipment(data: AgriShipmentSignReqVO) {
|
||||
return http.post<void>('/agri/biz/flow/shipment-sign', data)
|
||||
}
|
||||
45
src/api/agri/trace/snapshot.ts
Normal file
45
src/api/agri/trace/snapshot.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
export interface AgriTraceSnapshotVO {
|
||||
id: number
|
||||
traceCode: string
|
||||
batchId: number
|
||||
batchNo: string
|
||||
productName?: string
|
||||
plotName?: string
|
||||
harvestTime?: string
|
||||
harvestOperatorId?: number
|
||||
harvestOperatorName?: string
|
||||
packingTime?: string
|
||||
packingOperatorId?: number
|
||||
packingOperatorName?: string
|
||||
warehouseTime?: string
|
||||
warehouseOperatorId?: number
|
||||
warehouseOperatorName?: string
|
||||
shipmentTime?: string
|
||||
shipmentOperatorId?: number
|
||||
shipmentOperatorName?: string
|
||||
vehicleNo?: string
|
||||
invoiceStatus?: string
|
||||
snapshotJson?: string
|
||||
}
|
||||
|
||||
export interface AgriTraceSnapshotPageReqVO extends PageParam {
|
||||
batchId?: number
|
||||
batchNo?: string
|
||||
traceCode?: string
|
||||
productName?: string
|
||||
}
|
||||
|
||||
export function getAgriTraceSnapshotPage(params: AgriTraceSnapshotPageReqVO) {
|
||||
return http.get<PageResult<AgriTraceSnapshotVO>>('/agri/trace/snapshot/page', params)
|
||||
}
|
||||
|
||||
export function getAgriTraceSnapshot(id: number) {
|
||||
return http.get<AgriTraceSnapshotVO>(`/agri/trace/snapshot/get?id=${id}`)
|
||||
}
|
||||
|
||||
export function getAgriTraceSnapshotByTraceCode(traceCode: string) {
|
||||
return http.get<AgriTraceSnapshotVO>('/agri/trace/snapshot/get-by-trace-code', { traceCode })
|
||||
}
|
||||
13
src/api/erp/box/index.ts
Normal file
13
src/api/erp/box/index.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 框管理记录 */
|
||||
export interface Box {
|
||||
id?: number
|
||||
boxNumber: string
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
/** 获取框管理分页列表(用于提取框编号) */
|
||||
export function getBoxPage(params?: Record<string, any>) {
|
||||
return http.get<{ list: Box[], total: number }>('/erp/box/page', { pageNo: 1, pageSize: 100, ...params })
|
||||
}
|
||||
73
src/api/erp/farmer/index.ts
Normal file
73
src/api/erp/farmer/index.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 农户信息 */
|
||||
export interface Farmer {
|
||||
id?: number
|
||||
name?: string
|
||||
idCardNumber?: string
|
||||
mobile?: string
|
||||
address?: string
|
||||
plantingBase?: string
|
||||
contractNumber?: string
|
||||
contractedArea?: number
|
||||
orderQuantity?: number
|
||||
actualArea?: number
|
||||
transplantTime?: string
|
||||
transplantQuantity?: number
|
||||
maturityTime?: string
|
||||
expectedHarvestTime?: string
|
||||
usedVariety?: string
|
||||
plantingMethod?: string
|
||||
adminName?: string
|
||||
contact?: string
|
||||
telephone?: string
|
||||
email?: string
|
||||
fax?: string
|
||||
remark?: string
|
||||
status?: number
|
||||
sort?: number
|
||||
taxNo?: string
|
||||
taxPercent?: number
|
||||
bankName?: string
|
||||
bankAccount?: string
|
||||
bankAddress?: string
|
||||
}
|
||||
|
||||
/** 品种选项 */
|
||||
export const VARIETY_OPTIONS = [
|
||||
{ value: '红宝石', label: '红宝石' },
|
||||
{ value: '1401', label: '1401' },
|
||||
{ value: '1501', label: '1501' },
|
||||
{ value: '3366', label: '3366' },
|
||||
]
|
||||
|
||||
/** 获取农户分页列表 */
|
||||
export function getFarmerPage(params: PageParam) {
|
||||
return http.get<PageResult<Farmer>>('/erp/farmer/page', { ...params, type: 2 })
|
||||
}
|
||||
|
||||
/** 获取农户详情 */
|
||||
export function getFarmer(id: number) {
|
||||
return http.get<Farmer>(`/erp/farmer/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建农户 */
|
||||
export function createFarmer(data: Farmer) {
|
||||
return http.post<number>('/erp/farmer/create', data)
|
||||
}
|
||||
|
||||
/** 更新农户 */
|
||||
export function updateFarmer(data: Farmer) {
|
||||
return http.put<boolean>('/erp/farmer/update', data)
|
||||
}
|
||||
|
||||
/** 删除农户 */
|
||||
export function deleteFarmer(id: number) {
|
||||
return http.delete<boolean>(`/erp/farmer/delete?id=${id}`)
|
||||
}
|
||||
|
||||
/** 获取农户精简列表 */
|
||||
export function getFarmerSimpleList() {
|
||||
return http.get<Farmer[]>('/erp/farmer/simple-list')
|
||||
}
|
||||
13
src/api/erp/farming/index.ts
Normal file
13
src/api/erp/farming/index.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 田间管理记录 */
|
||||
export interface FarmingManagement {
|
||||
id?: number
|
||||
code: string
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
/** 获取田间管理分页列表(用于提取田间编号) */
|
||||
export function getFarmingManagementPage(params?: Record<string, any>) {
|
||||
return http.get<{ list: FarmingManagement[], total: number }>('/erp/farming-management/page', { pageNo: 1, pageSize: 100, ...params })
|
||||
}
|
||||
85
src/api/erp/pick-broccoli/index.ts
Normal file
85
src/api/erp/pick-broccoli/index.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 西兰花采摘记录信息 */
|
||||
export interface PickBroccoli {
|
||||
id?: number
|
||||
pickCode?: string
|
||||
userId?: number
|
||||
userName?: string
|
||||
fieldCode?: string
|
||||
fieldName?: string
|
||||
basketCode?: string
|
||||
basketWeight?: number
|
||||
licensePlate?: string
|
||||
pickTime?: string
|
||||
loadTime?: string
|
||||
loaderId?: number
|
||||
loaderName?: string
|
||||
status?: number
|
||||
unloadTime?: string
|
||||
unloaderId?: number
|
||||
unloaderName?: string
|
||||
warehouseId?: string
|
||||
warehouseName?: string
|
||||
unloadBatch?: string
|
||||
productId?: number
|
||||
productName?: string
|
||||
remark?: string
|
||||
createTime?: string
|
||||
}
|
||||
|
||||
/** 获取采摘记录分页列表 */
|
||||
export function getPickBroccoliPage(params: PageParam) {
|
||||
return http.get<PageResult<PickBroccoli>>('/erp/pick-broccoli/page', params)
|
||||
}
|
||||
|
||||
/** 获取采摘记录详情 */
|
||||
export function getPickBroccoli(id: number) {
|
||||
return http.get<PickBroccoli>(`/erp/pick-broccoli/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建采摘记录 */
|
||||
export function createPickBroccoli(data: PickBroccoli) {
|
||||
return http.post<number>('/erp/pick-broccoli/create', data)
|
||||
}
|
||||
|
||||
/** 更新采摘记录 */
|
||||
export function updatePickBroccoli(data: PickBroccoli) {
|
||||
return http.put<boolean>('/erp/pick-broccoli/update', data)
|
||||
}
|
||||
|
||||
/** 删除采摘记录 */
|
||||
export function deletePickBroccoli(id: number) {
|
||||
return http.delete<boolean>(`/erp/pick-broccoli/delete?id=${id}`)
|
||||
}
|
||||
|
||||
/** 更新采摘记录状态 */
|
||||
export function updatePickBroccoliStatus(id: number, status: number) {
|
||||
return http.put<boolean>(`/erp/pick-broccoli/update-status?id=${id}&status=${status}`)
|
||||
}
|
||||
|
||||
/** 装车操作 */
|
||||
export function loadTruck(id: number, licensePlate: string, loaderId: number, loaderName: string) {
|
||||
return http.put<boolean>(`/erp/pick-broccoli/load-truck?id=${id}&licensePlate=${licensePlate}&loaderId=${loaderId}&loaderName=${loaderName}`)
|
||||
}
|
||||
|
||||
/** 卸车入库操作 */
|
||||
export function unloadTruck(licensePlate: string, unloaderId: number, unloaderName: string, warehouseId: string, warehouseName: string) {
|
||||
return http.put<boolean>(`/erp/pick-broccoli/unload-truck?licensePlate=${licensePlate}&unloaderId=${unloaderId}&unloaderName=${unloaderName}&warehouseId=${warehouseId}&warehouseName=${warehouseName}`)
|
||||
}
|
||||
|
||||
/** 获取已装车车辆列表 */
|
||||
export function getLoadedTrucks() {
|
||||
return http.get<any[]>('/erp/pick-broccoli/list-loaded-trucks')
|
||||
}
|
||||
|
||||
/** 卸车预览 */
|
||||
export function getUnloadPreview(licensePlate: string) {
|
||||
return http.get<any>(`/erp/pick-broccoli/unload-preview?licensePlate=${licensePlate}`)
|
||||
}
|
||||
|
||||
/** 生成采摘编号 */
|
||||
export function generatePickCode() {
|
||||
return http.get<{ code: string }>('/erp/pick-broccoli/generate-code')
|
||||
}
|
||||
22
src/api/erp/product/index.ts
Normal file
22
src/api/erp/product/index.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 产品精简信息 */
|
||||
export interface ProductSimple {
|
||||
id: number
|
||||
name: string
|
||||
barCode?: string
|
||||
unitId?: number
|
||||
unitName?: string
|
||||
standard?: string
|
||||
purchasePrice?: number
|
||||
salePrice?: number
|
||||
minPrice?: number
|
||||
supplierId?: number
|
||||
supplierName?: string
|
||||
weight?: number
|
||||
}
|
||||
|
||||
/** 获取产品精简列表 */
|
||||
export function getProductSimpleList() {
|
||||
return http.get<ProductSimple[]>('/erp/product/simple-list')
|
||||
}
|
||||
109
src/api/erp/purchase-in/index.ts
Normal file
109
src/api/erp/purchase-in/index.ts
Normal file
@@ -0,0 +1,109 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 采购入库项 */
|
||||
export interface PurchaseInItem {
|
||||
id?: number
|
||||
productId: number
|
||||
productUnitId: number
|
||||
productPrice?: number
|
||||
count: number
|
||||
taxPercent?: number
|
||||
taxPrice?: number
|
||||
remark?: string
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
productName?: string
|
||||
productBarCode?: string
|
||||
productUnitName?: string
|
||||
productSpec?: string
|
||||
productCategoryName?: string
|
||||
stockCount?: number
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
totalProductPrice?: number
|
||||
orderItemId?: number
|
||||
}
|
||||
|
||||
/** 采购入库信息 */
|
||||
export interface PurchaseIn {
|
||||
id?: number
|
||||
no?: string
|
||||
status?: number
|
||||
supplierId?: number
|
||||
supplierName?: string
|
||||
accountId?: number
|
||||
accountName?: string
|
||||
inTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
totalProductPrice?: number
|
||||
totalTaxPrice?: number
|
||||
discountPercent?: number
|
||||
discountPrice?: number
|
||||
otherPrice?: number
|
||||
paymentPrice?: number
|
||||
fileUrl?: string
|
||||
remark?: string
|
||||
creator?: string
|
||||
creatorName?: string
|
||||
createTime?: string
|
||||
items?: PurchaseInItem[]
|
||||
productNames?: string
|
||||
orderId?: number
|
||||
orderNo?: string
|
||||
isQualified?: boolean
|
||||
returnType?: string | null
|
||||
returnRemark?: string
|
||||
}
|
||||
|
||||
/** 审核表单数据 */
|
||||
export interface AuditFormData {
|
||||
id: number
|
||||
isQualified: boolean
|
||||
returnType?: string
|
||||
returnRemark?: string
|
||||
status: number
|
||||
}
|
||||
|
||||
/** 返回方式枚举 */
|
||||
export const RETURN_TYPE_ENUM = {
|
||||
RETURN_BACK: 'return_back',
|
||||
DESTROY: 'destroy',
|
||||
}
|
||||
|
||||
/** 返回方式选项 */
|
||||
export const RETURN_TYPE_OPTIONS = [
|
||||
{ label: '原路返回', value: RETURN_TYPE_ENUM.RETURN_BACK },
|
||||
{ label: '就地销毁', value: RETURN_TYPE_ENUM.DESTROY },
|
||||
]
|
||||
|
||||
/** 获取采购入库分页列表 */
|
||||
export function getPurchaseInPage(params: PageParam) {
|
||||
return http.get<PageResult<PurchaseIn>>('/erp/purchase-in/page', params)
|
||||
}
|
||||
|
||||
/** 获取采购入库详情 */
|
||||
export function getPurchaseIn(id: number) {
|
||||
return http.get<PurchaseIn>(`/erp/purchase-in/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建采购入库 */
|
||||
export function createPurchaseIn(data: PurchaseIn) {
|
||||
return http.post<number>('/erp/purchase-in/create', data)
|
||||
}
|
||||
|
||||
/** 更新采购入库 */
|
||||
export function updatePurchaseIn(data: PurchaseIn) {
|
||||
return http.put<boolean>('/erp/purchase-in/update', data)
|
||||
}
|
||||
|
||||
/** 更新采购入库状态 */
|
||||
export function updatePurchaseInStatus(data: AuditFormData) {
|
||||
return http.put<boolean>('/erp/purchase-in/update-status', data)
|
||||
}
|
||||
|
||||
/** 删除采购入库 */
|
||||
export function deletePurchaseIn(ids: number[]) {
|
||||
return http.delete<boolean>(`/erp/purchase-in/delete?ids=${ids.join(',')}`)
|
||||
}
|
||||
90
src/api/erp/purchase-order/index.ts
Normal file
90
src/api/erp/purchase-order/index.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 采购订单项 */
|
||||
export interface PurchaseOrderItem {
|
||||
id?: number
|
||||
productId: number
|
||||
productUnitId: number
|
||||
productPrice?: number
|
||||
count: number
|
||||
taxPercent?: number
|
||||
taxPrice?: number
|
||||
remark?: string
|
||||
inCount?: number
|
||||
returnCount?: number
|
||||
supplierId?: number
|
||||
supplierName?: string
|
||||
productName?: string
|
||||
productBarCode?: string
|
||||
productUnitName?: string
|
||||
stockCount?: number
|
||||
productSpec?: string
|
||||
}
|
||||
|
||||
/** 采购订单信息 */
|
||||
export interface PurchaseOrder {
|
||||
id?: number
|
||||
no?: string
|
||||
status?: number
|
||||
supplierId?: number
|
||||
supplierName?: string
|
||||
accountId?: number
|
||||
orderTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
totalProductPrice?: number
|
||||
totalTaxPrice?: number
|
||||
discountPercent?: number
|
||||
discountPrice?: number
|
||||
depositPrice?: number
|
||||
fileUrl?: string
|
||||
remark?: string
|
||||
creator?: string
|
||||
creatorName?: string
|
||||
createTime?: string
|
||||
items?: PurchaseOrderItem[]
|
||||
productNames?: string
|
||||
inCount?: number
|
||||
returnCount?: number
|
||||
auditorId?: number
|
||||
auditorName?: string
|
||||
purchaseRequisitionId?: number
|
||||
purchaseRequisitionNo?: string
|
||||
invoiceType?: number
|
||||
invoiceTypeName?: string
|
||||
freightPayer?: number
|
||||
freightPayerName?: string
|
||||
settlementMethod?: number
|
||||
settlementMethodName?: string
|
||||
}
|
||||
|
||||
/** 获取采购订单分页列表 */
|
||||
export function getPurchaseOrderPage(params: PageParam) {
|
||||
return http.get<PageResult<PurchaseOrder>>('/erp/purchase-order/page', params)
|
||||
}
|
||||
|
||||
/** 获取采购订单详情 */
|
||||
export function getPurchaseOrder(id: number) {
|
||||
return http.get<PurchaseOrder>(`/erp/purchase-order/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建采购订单 */
|
||||
export function createPurchaseOrder(data: PurchaseOrder) {
|
||||
return http.post<number>('/erp/purchase-order/create', data)
|
||||
}
|
||||
|
||||
/** 更新采购订单 */
|
||||
export function updatePurchaseOrder(data: PurchaseOrder) {
|
||||
return http.put<boolean>('/erp/purchase-order/update', data)
|
||||
}
|
||||
|
||||
/** 更新采购订单状态 */
|
||||
export function updatePurchaseOrderStatus(id: number, status: number) {
|
||||
return http.put<boolean>(`/erp/purchase-order/update-status?id=${id}&status=${status}`)
|
||||
}
|
||||
|
||||
/** 删除采购订单 */
|
||||
export function deletePurchaseOrder(ids: number[]) {
|
||||
return http.delete<boolean>(`/erp/purchase-order/delete?ids=${ids.join(',')}`)
|
||||
}
|
||||
126
src/api/erp/purchase-requisition/index.ts
Normal file
126
src/api/erp/purchase-requisition/index.ts
Normal file
@@ -0,0 +1,126 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 请购单明细信息 */
|
||||
export interface PurchaseRequisitionItem {
|
||||
id?: number
|
||||
requisitionId?: number
|
||||
productId?: number
|
||||
productName?: string
|
||||
productUnitId?: number
|
||||
productUnitName?: string
|
||||
productSpec?: string
|
||||
productBarCode?: string
|
||||
productPrice?: number
|
||||
count?: number
|
||||
totalProductPrice?: number
|
||||
taxPercent?: number
|
||||
taxPrice?: number
|
||||
totalPrice?: number
|
||||
purpose?: string
|
||||
brandId?: number
|
||||
brandName?: string
|
||||
supplierId?: number
|
||||
supplierName?: string
|
||||
approveCount?: number
|
||||
purchaseCount?: number
|
||||
remark?: string
|
||||
createTime?: string
|
||||
saleOrderId?: number
|
||||
saleOrderNo?: string
|
||||
}
|
||||
|
||||
/** 请购单信息 */
|
||||
export interface PurchaseRequisition {
|
||||
id?: number
|
||||
no?: string
|
||||
type?: number
|
||||
priority?: number
|
||||
status?: number
|
||||
requesterId?: number
|
||||
requesterName?: string
|
||||
requesterNickname?: string
|
||||
requesterDeptId?: number
|
||||
requesterDeptName?: string
|
||||
requestTime?: string
|
||||
expectedTime?: string
|
||||
approverId?: number
|
||||
approverName?: string
|
||||
approveTime?: string
|
||||
approveRemark?: string
|
||||
totalCount?: number
|
||||
totalProductPrice?: number
|
||||
totalTaxPrice?: number
|
||||
totalPrice?: number
|
||||
additionalFee?: number
|
||||
emergencyDegree?: number
|
||||
fileUrl?: string
|
||||
remark?: string
|
||||
supplierId?: number
|
||||
supplierName?: string
|
||||
items?: PurchaseRequisitionItem[]
|
||||
hasApprovalRecords?: boolean
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 获取请购单分页列表 */
|
||||
export function getPurchaseRequisitionPage(params: PageParam) {
|
||||
return http.get<PageResult<PurchaseRequisition>>('/erp/purchase-requisition/page', params)
|
||||
}
|
||||
|
||||
/** 获取请购单详情 */
|
||||
export function getPurchaseRequisition(id: number) {
|
||||
return http.get<PurchaseRequisition>(`/erp/purchase-requisition/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建请购单 */
|
||||
export function createPurchaseRequisition(data: PurchaseRequisition) {
|
||||
return http.post<number>('/erp/purchase-requisition/create', data)
|
||||
}
|
||||
|
||||
/** 更新请购单 */
|
||||
export function updatePurchaseRequisition(data: PurchaseRequisition) {
|
||||
return http.put<boolean>('/erp/purchase-requisition/update', data)
|
||||
}
|
||||
|
||||
/** 删除请购单 */
|
||||
export function deletePurchaseRequisition(id: number) {
|
||||
return http.delete<boolean>(`/erp/purchase-requisition/delete?id=${id}`)
|
||||
}
|
||||
|
||||
/** 更新请购单状态 */
|
||||
export function updatePurchaseRequisitionStatus(id: number, status: number) {
|
||||
return http.put<boolean>(`/erp/purchase-requisition/update-status?id=${id}&status=${status}`)
|
||||
}
|
||||
|
||||
/** 请购类型选项 */
|
||||
export const REQUISITION_TYPE_OPTIONS = [
|
||||
{ value: 1, label: '请购' },
|
||||
{ value: 2, label: '补货' },
|
||||
{ value: 3, label: '其他' },
|
||||
]
|
||||
|
||||
/** 优先级选项 */
|
||||
export const PRIORITY_OPTIONS = [
|
||||
{ value: 1, label: '低' },
|
||||
{ value: 2, label: '中' },
|
||||
{ value: 3, label: '高' },
|
||||
{ value: 4, label: '紧急' },
|
||||
]
|
||||
|
||||
/** 状态选项 */
|
||||
export const STATUS_OPTIONS = [
|
||||
{ value: 1, label: '待审核' },
|
||||
{ value: 2, label: '已审核' },
|
||||
{ value: 3, label: '已驳回' },
|
||||
{ value: 4, label: '已取消' },
|
||||
{ value: 5, label: '已采购' },
|
||||
]
|
||||
|
||||
/** 紧急程度选项 */
|
||||
export const EMERGENCY_OPTIONS = [
|
||||
{ value: 1, label: '普通' },
|
||||
{ value: 2, label: '较急' },
|
||||
{ value: 3, label: '紧急' },
|
||||
{ value: 4, label: '特急' },
|
||||
]
|
||||
87
src/api/erp/purchase-return/index.ts
Normal file
87
src/api/erp/purchase-return/index.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 采购退货项 */
|
||||
export interface PurchaseReturnItem {
|
||||
id?: number
|
||||
productId: number
|
||||
productUnitId: number
|
||||
productPrice?: number
|
||||
count: number
|
||||
taxPercent?: number
|
||||
taxPrice?: number
|
||||
remark?: string
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
productName?: string
|
||||
productBarCode?: string
|
||||
productUnitName?: string
|
||||
productSpec?: string
|
||||
productCategoryName?: string
|
||||
stockCount?: number
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
totalProductPrice?: number
|
||||
orderItemId?: number
|
||||
inCount?: number
|
||||
returnCount?: number
|
||||
}
|
||||
|
||||
/** 采购退货信息 */
|
||||
export interface PurchaseReturn {
|
||||
id?: number
|
||||
no?: string
|
||||
status?: number
|
||||
supplierId?: number
|
||||
supplierName?: string
|
||||
accountId?: number
|
||||
accountName?: string
|
||||
returnTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
totalProductPrice?: number
|
||||
totalTaxPrice?: number
|
||||
discountPercent?: number
|
||||
discountPrice?: number
|
||||
otherPrice?: number
|
||||
refundPrice?: number
|
||||
fileUrl?: string
|
||||
remark?: string
|
||||
creator?: string
|
||||
creatorName?: string
|
||||
createTime?: string
|
||||
items?: PurchaseReturnItem[]
|
||||
productNames?: string
|
||||
orderId?: number
|
||||
orderNo?: string
|
||||
}
|
||||
|
||||
/** 获取采购退货分页列表 */
|
||||
export function getPurchaseReturnPage(params: PageParam) {
|
||||
return http.get<PageResult<PurchaseReturn>>('/erp/purchase-return/page', params)
|
||||
}
|
||||
|
||||
/** 获取采购退货详情 */
|
||||
export function getPurchaseReturn(id: number) {
|
||||
return http.get<PurchaseReturn>(`/erp/purchase-return/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建采购退货 */
|
||||
export function createPurchaseReturn(data: PurchaseReturn) {
|
||||
return http.post<number>('/erp/purchase-return/create', data)
|
||||
}
|
||||
|
||||
/** 更新采购退货 */
|
||||
export function updatePurchaseReturn(data: PurchaseReturn) {
|
||||
return http.put<boolean>('/erp/purchase-return/update', data)
|
||||
}
|
||||
|
||||
/** 更新采购退货状态 */
|
||||
export function updatePurchaseReturnStatus(id: number, status: number) {
|
||||
return http.put<boolean>(`/erp/purchase-return/update-status?id=${id}&status=${status}`)
|
||||
}
|
||||
|
||||
/** 删除采购退货 */
|
||||
export function deletePurchaseReturn(ids: number[]) {
|
||||
return http.delete<boolean>(`/erp/purchase-return/delete?ids=${ids.join(',')}`)
|
||||
}
|
||||
64
src/api/erp/stock-check/index.ts
Normal file
64
src/api/erp/stock-check/index.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 盘点单项 */
|
||||
export interface StockCheckItem {
|
||||
id?: number
|
||||
stockCheckId?: number
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
productId?: number
|
||||
productName?: string
|
||||
productUnitName?: string
|
||||
stockCount?: number
|
||||
actualCount?: number
|
||||
count?: number
|
||||
productPrice?: number
|
||||
totalPrice?: number
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 盘点单信息 */
|
||||
export interface StockCheck {
|
||||
id?: number
|
||||
no?: string
|
||||
checkTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
status?: number
|
||||
remark?: string
|
||||
items?: StockCheckItem[]
|
||||
productNames?: string
|
||||
creatorName?: string
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 获取盘点单分页列表 */
|
||||
export function getStockCheckPage(params: PageParam) {
|
||||
return http.get<PageResult<StockCheck>>('/erp/stock-check/page', params)
|
||||
}
|
||||
|
||||
/** 获取盘点单详情 */
|
||||
export function getStockCheck(id: number) {
|
||||
return http.get<StockCheck>(`/erp/stock-check/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建盘点单 */
|
||||
export function createStockCheck(data: StockCheck) {
|
||||
return http.post<number>('/erp/stock-check/create', data)
|
||||
}
|
||||
|
||||
/** 更新盘点单 */
|
||||
export function updateStockCheck(data: StockCheck) {
|
||||
return http.put<boolean>('/erp/stock-check/update', data)
|
||||
}
|
||||
|
||||
/** 更新盘点单状态 */
|
||||
export function updateStockCheckStatus(id: number, status: number) {
|
||||
return http.put<boolean>('/erp/stock-check/update-status', undefined, { id, status })
|
||||
}
|
||||
|
||||
/** 删除盘点单 */
|
||||
export function deleteStockCheck(ids: number[]) {
|
||||
return http.delete<boolean>('/erp/stock-check/delete', undefined, { ids: ids.join(',') })
|
||||
}
|
||||
63
src/api/erp/stock-gain/index.ts
Normal file
63
src/api/erp/stock-gain/index.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 报溢单项 */
|
||||
export interface StockGainItem {
|
||||
id?: number
|
||||
stockGainId?: number
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
productId?: number
|
||||
productName?: string
|
||||
productUnitName?: string
|
||||
count?: number
|
||||
productPrice?: number
|
||||
totalPrice?: number
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 报溢单信息 */
|
||||
export interface StockGain {
|
||||
id?: number
|
||||
no?: string
|
||||
gainTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
status?: number
|
||||
reason?: string
|
||||
remark?: string
|
||||
items?: StockGainItem[]
|
||||
productNames?: string
|
||||
creatorName?: string
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 获取报溢单分页列表 */
|
||||
export function getStockGainPage(params: PageParam) {
|
||||
return http.get<PageResult<StockGain>>('/erp/stock-gain/page', params)
|
||||
}
|
||||
|
||||
/** 获取报溢单详情 */
|
||||
export function getStockGain(id: number) {
|
||||
return http.get<StockGain>(`/erp/stock-gain/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建报溢单 */
|
||||
export function createStockGain(data: StockGain) {
|
||||
return http.post<number>('/erp/stock-gain/create', data)
|
||||
}
|
||||
|
||||
/** 更新报溢单 */
|
||||
export function updateStockGain(data: StockGain) {
|
||||
return http.put<boolean>('/erp/stock-gain/update', data)
|
||||
}
|
||||
|
||||
/** 更新报溢单状态 */
|
||||
export function updateStockGainStatus(id: number, status: number) {
|
||||
return http.put<boolean>('/erp/stock-gain/update-status', undefined, { id, status })
|
||||
}
|
||||
|
||||
/** 删除报溢单 */
|
||||
export function deleteStockGain(ids: number[]) {
|
||||
return http.delete<boolean>('/erp/stock-gain/delete', undefined, { ids: ids.join(',') })
|
||||
}
|
||||
64
src/api/erp/stock-in/index.ts
Normal file
64
src/api/erp/stock-in/index.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 其他入库单项 */
|
||||
export interface StockInItem {
|
||||
id?: number
|
||||
stockInId?: number
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
productId?: number
|
||||
productName?: string
|
||||
productUnitName?: string
|
||||
count?: number
|
||||
productPrice?: number
|
||||
totalPrice?: number
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 其他入库单信息 */
|
||||
export interface StockIn {
|
||||
id?: number
|
||||
no?: string
|
||||
supplierId?: number
|
||||
supplierName?: string
|
||||
inTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
status?: number
|
||||
remark?: string
|
||||
items?: StockInItem[]
|
||||
productNames?: string
|
||||
creatorName?: string
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 获取其他入库单分页列表 */
|
||||
export function getStockInPage(params: PageParam) {
|
||||
return http.get<PageResult<StockIn>>('/erp/stock-in/page', params)
|
||||
}
|
||||
|
||||
/** 获取其他入库单详情 */
|
||||
export function getStockIn(id: number) {
|
||||
return http.get<StockIn>(`/erp/stock-in/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建其他入库单 */
|
||||
export function createStockIn(data: StockIn) {
|
||||
return http.post<number>('/erp/stock-in/create', data)
|
||||
}
|
||||
|
||||
/** 更新其他入库单 */
|
||||
export function updateStockIn(data: StockIn) {
|
||||
return http.put<boolean>('/erp/stock-in/update', data)
|
||||
}
|
||||
|
||||
/** 更新其他入库单状态 */
|
||||
export function updateStockInStatus(id: number, status: number) {
|
||||
return http.put<boolean>('/erp/stock-in/update-status', undefined, { id, status })
|
||||
}
|
||||
|
||||
/** 删除其他入库单 */
|
||||
export function deleteStockIn(ids: number[]) {
|
||||
return http.delete<boolean>('/erp/stock-in/delete', undefined, { ids: ids.join(',') })
|
||||
}
|
||||
63
src/api/erp/stock-loss/index.ts
Normal file
63
src/api/erp/stock-loss/index.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 报损单项 */
|
||||
export interface StockLossItem {
|
||||
id?: number
|
||||
stockLossId?: number
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
productId?: number
|
||||
productName?: string
|
||||
productUnitName?: string
|
||||
count?: number
|
||||
productPrice?: number
|
||||
totalPrice?: number
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 报损单信息 */
|
||||
export interface StockLoss {
|
||||
id?: number
|
||||
no?: string
|
||||
lossTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
status?: number
|
||||
reason?: string
|
||||
remark?: string
|
||||
items?: StockLossItem[]
|
||||
productNames?: string
|
||||
creatorName?: string
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 获取报损单分页列表 */
|
||||
export function getStockLossPage(params: PageParam) {
|
||||
return http.get<PageResult<StockLoss>>('/erp/stock-loss/page', params)
|
||||
}
|
||||
|
||||
/** 获取报损单详情 */
|
||||
export function getStockLoss(id: number) {
|
||||
return http.get<StockLoss>(`/erp/stock-loss/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建报损单 */
|
||||
export function createStockLoss(data: StockLoss) {
|
||||
return http.post<number>('/erp/stock-loss/create', data)
|
||||
}
|
||||
|
||||
/** 更新报损单 */
|
||||
export function updateStockLoss(data: StockLoss) {
|
||||
return http.put<boolean>('/erp/stock-loss/update', data)
|
||||
}
|
||||
|
||||
/** 更新报损单状态 */
|
||||
export function updateStockLossStatus(id: number, status: number) {
|
||||
return http.put<boolean>('/erp/stock-loss/update-status', undefined, { id, status })
|
||||
}
|
||||
|
||||
/** 删除报损单 */
|
||||
export function deleteStockLoss(ids: number[]) {
|
||||
return http.delete<boolean>('/erp/stock-loss/delete', undefined, { ids: ids.join(',') })
|
||||
}
|
||||
64
src/api/erp/stock-move/index.ts
Normal file
64
src/api/erp/stock-move/index.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 调拨单项 */
|
||||
export interface StockMoveItem {
|
||||
id?: number
|
||||
stockMoveId?: number
|
||||
fromWarehouseId?: number
|
||||
fromWarehouseName?: string
|
||||
toWarehouseId?: number
|
||||
toWarehouseName?: string
|
||||
productId?: number
|
||||
productName?: string
|
||||
productUnitName?: string
|
||||
count?: number
|
||||
productPrice?: number
|
||||
totalPrice?: number
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 调拨单信息 */
|
||||
export interface StockMove {
|
||||
id?: number
|
||||
no?: string
|
||||
moveTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
status?: number
|
||||
remark?: string
|
||||
items?: StockMoveItem[]
|
||||
productNames?: string
|
||||
creatorName?: string
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 获取调拨单分页列表 */
|
||||
export function getStockMovePage(params: PageParam) {
|
||||
return http.get<PageResult<StockMove>>('/erp/stock-move/page', params)
|
||||
}
|
||||
|
||||
/** 获取调拨单详情 */
|
||||
export function getStockMove(id: number) {
|
||||
return http.get<StockMove>(`/erp/stock-move/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建调拨单 */
|
||||
export function createStockMove(data: StockMove) {
|
||||
return http.post<number>('/erp/stock-move/create', data)
|
||||
}
|
||||
|
||||
/** 更新调拨单 */
|
||||
export function updateStockMove(data: StockMove) {
|
||||
return http.put<boolean>('/erp/stock-move/update', data)
|
||||
}
|
||||
|
||||
/** 更新调拨单状态 */
|
||||
export function updateStockMoveStatus(id: number, status: number) {
|
||||
return http.put<boolean>('/erp/stock-move/update-status', undefined, { id, status })
|
||||
}
|
||||
|
||||
/** 删除调拨单 */
|
||||
export function deleteStockMove(ids: number[]) {
|
||||
return http.delete<boolean>('/erp/stock-move/delete', undefined, { ids: ids.join(',') })
|
||||
}
|
||||
64
src/api/erp/stock-out/index.ts
Normal file
64
src/api/erp/stock-out/index.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 其他出库单项 */
|
||||
export interface StockOutItem {
|
||||
id?: number
|
||||
stockOutId?: number
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
productId?: number
|
||||
productName?: string
|
||||
productUnitName?: string
|
||||
count?: number
|
||||
productPrice?: number
|
||||
totalPrice?: number
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 其他出库单信息 */
|
||||
export interface StockOut {
|
||||
id?: number
|
||||
no?: string
|
||||
customerId?: number
|
||||
customerName?: string
|
||||
outTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
status?: number
|
||||
remark?: string
|
||||
items?: StockOutItem[]
|
||||
productNames?: string
|
||||
creatorName?: string
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 获取其他出库单分页列表 */
|
||||
export function getStockOutPage(params: PageParam) {
|
||||
return http.get<PageResult<StockOut>>('/erp/stock-out/page', params)
|
||||
}
|
||||
|
||||
/** 获取其他出库单详情 */
|
||||
export function getStockOut(id: number) {
|
||||
return http.get<StockOut>(`/erp/stock-out/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建其他出库单 */
|
||||
export function createStockOut(data: StockOut) {
|
||||
return http.post<number>('/erp/stock-out/create', data)
|
||||
}
|
||||
|
||||
/** 更新其他出库单 */
|
||||
export function updateStockOut(data: StockOut) {
|
||||
return http.put<boolean>('/erp/stock-out/update', data)
|
||||
}
|
||||
|
||||
/** 更新其他出库单状态 */
|
||||
export function updateStockOutStatus(id: number, status: number) {
|
||||
return http.put<boolean>('/erp/stock-out/update-status', undefined, { id, status })
|
||||
}
|
||||
|
||||
/** 删除其他出库单 */
|
||||
export function deleteStockOut(ids: number[]) {
|
||||
return http.delete<boolean>('/erp/stock-out/delete', undefined, { ids: ids.join(',') })
|
||||
}
|
||||
45
src/api/erp/stock-record/index.ts
Normal file
45
src/api/erp/stock-record/index.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 产品库存明细信息 */
|
||||
export interface StockRecord {
|
||||
id?: number
|
||||
productId?: number
|
||||
productName?: string
|
||||
unitName?: string
|
||||
categoryName?: string
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
count?: number
|
||||
totalCount?: number
|
||||
bizType?: number
|
||||
bizId?: number
|
||||
bizItemId?: number
|
||||
bizNo?: string
|
||||
unitPrice?: number
|
||||
stockValue?: number
|
||||
creatorName?: string
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 业务类型选项 */
|
||||
export const BIZ_TYPE_OPTIONS = [
|
||||
{ value: 1, label: '采购入库' },
|
||||
{ value: 2, label: '采购退货' },
|
||||
{ value: 3, label: '销售出库' },
|
||||
{ value: 4, label: '销售退货' },
|
||||
{ value: 10, label: '其他入库' },
|
||||
{ value: 11, label: '其他出库' },
|
||||
{ value: 12, label: '库存调拨' },
|
||||
{ value: 13, label: '库存盘点' },
|
||||
]
|
||||
|
||||
/** 获取产品库存明细分页列表 */
|
||||
export function getStockRecordPage(params: PageParam) {
|
||||
return http.get<PageResult<StockRecord>>('/erp/stock-record/page', params)
|
||||
}
|
||||
|
||||
/** 获取产品库存明细详情 */
|
||||
export function getStockRecord(id: number) {
|
||||
return http.get<StockRecord>(`/erp/stock-record/get?id=${id}`)
|
||||
}
|
||||
40
src/api/erp/stock/index.ts
Normal file
40
src/api/erp/stock/index.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 产品库存信息 */
|
||||
export interface Stock {
|
||||
id?: number
|
||||
productId?: number
|
||||
productName?: string
|
||||
unitName?: string
|
||||
categoryName?: string
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
count?: number
|
||||
unitPrice?: number
|
||||
stockValue?: number
|
||||
}
|
||||
|
||||
/** 获取产品库存分页列表 */
|
||||
export function getStockPage(params: PageParam) {
|
||||
return http.get<PageResult<Stock>>('/erp/stock/page', params)
|
||||
}
|
||||
|
||||
/** 获取产品库存详情 */
|
||||
export function getStock(id: number) {
|
||||
return http.get<Stock>(`/erp/stock/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 获取产品库存详情(通过产品ID和仓库ID) */
|
||||
export function getStock2(productId: number, warehouseId: number) {
|
||||
return http.get<Stock>('/erp/stock/get', { productId, warehouseId })
|
||||
}
|
||||
|
||||
/** 获取产品库存数量 */
|
||||
export function getStockCount(productId: number, warehouseId?: number) {
|
||||
const params: Record<string, any> = { productId }
|
||||
if (warehouseId) {
|
||||
params.warehouseId = warehouseId
|
||||
}
|
||||
return http.get<number>('/erp/stock/get-count', params)
|
||||
}
|
||||
57
src/api/erp/supplier/index.ts
Normal file
57
src/api/erp/supplier/index.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 供应商信息 */
|
||||
export interface Supplier {
|
||||
id?: number
|
||||
name?: string
|
||||
contact?: string
|
||||
mobile?: string
|
||||
telephone?: string
|
||||
email?: string
|
||||
fax?: string
|
||||
remark?: string
|
||||
status?: number
|
||||
sort?: number
|
||||
taxNo?: string
|
||||
taxPercent?: number
|
||||
bankName?: string
|
||||
bankAccount?: string
|
||||
bankAddress?: string
|
||||
}
|
||||
|
||||
/** 供应商精简信息 */
|
||||
export interface SupplierSimple {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
|
||||
/** 获取供应商分页列表 */
|
||||
export function getSupplierPage(params: PageParam) {
|
||||
return http.get<PageResult<Supplier>>('/erp/supplier/page', { ...params, type: 1 })
|
||||
}
|
||||
|
||||
/** 获取供应商详情 */
|
||||
export function getSupplier(id: number) {
|
||||
return http.get<Supplier>(`/erp/supplier/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建供应商 */
|
||||
export function createSupplier(data: Supplier) {
|
||||
return http.post<number>('/erp/supplier/create', data)
|
||||
}
|
||||
|
||||
/** 更新供应商 */
|
||||
export function updateSupplier(data: Supplier) {
|
||||
return http.put<boolean>('/erp/supplier/update', data)
|
||||
}
|
||||
|
||||
/** 删除供应商 */
|
||||
export function deleteSupplier(id: number) {
|
||||
return http.delete<boolean>(`/erp/supplier/delete?id=${id}`)
|
||||
}
|
||||
|
||||
/** 获取供应商精简列表 */
|
||||
export function getSupplierSimpleList() {
|
||||
return http.get<SupplierSimple[]>('/erp/supplier/simple-list')
|
||||
}
|
||||
52
src/api/erp/warehouse/index.ts
Normal file
52
src/api/erp/warehouse/index.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 仓库信息 */
|
||||
export interface Warehouse {
|
||||
id?: number
|
||||
name?: string
|
||||
address?: string
|
||||
sort?: number
|
||||
remark?: string
|
||||
principal?: string
|
||||
warehousePrice?: number
|
||||
truckagePrice?: number
|
||||
status?: number
|
||||
defaultStatus?: boolean
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 获取仓库分页列表 */
|
||||
export function getWarehousePage(params: PageParam) {
|
||||
return http.get<PageResult<Warehouse>>('/erp/warehouse/page', params)
|
||||
}
|
||||
|
||||
/** 获取仓库详情 */
|
||||
export function getWarehouse(id: number) {
|
||||
return http.get<Warehouse>(`/erp/warehouse/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建仓库 */
|
||||
export function createWarehouse(data: Warehouse) {
|
||||
return http.post<number>('/erp/warehouse/create', data)
|
||||
}
|
||||
|
||||
/** 更新仓库 */
|
||||
export function updateWarehouse(data: Warehouse) {
|
||||
return http.put<boolean>('/erp/warehouse/update', data)
|
||||
}
|
||||
|
||||
/** 更新仓库默认状态 */
|
||||
export function updateWarehouseDefaultStatus(id: number, defaultStatus: boolean) {
|
||||
return http.put<boolean>('/erp/warehouse/update-default-status', undefined, { id, defaultStatus })
|
||||
}
|
||||
|
||||
/** 删除仓库 */
|
||||
export function deleteWarehouse(id: number) {
|
||||
return http.delete<boolean>(`/erp/warehouse/delete?id=${id}`)
|
||||
}
|
||||
|
||||
/** 获取仓库精简列表 */
|
||||
export function getWarehouseSimpleList() {
|
||||
return http.get<Warehouse[]>('/erp/warehouse/simple-list')
|
||||
}
|
||||
437
src/pages-agri/biz-flow/index.vue
Normal file
437
src/pages-agri/biz-flow/index.vue
Normal file
@@ -0,0 +1,437 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="闭环操作台"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 流程说明 -->
|
||||
<view class="mx-24rpx mt-20rpx mb-16rpx px-24rpx py-16rpx rounded-12rpx bg-[#e6f7ff] text-24rpx text-[#1890ff]">
|
||||
最小闭环操作台:采收 → 分拣 → 装箱 → 入库 → 发运 → 签收
|
||||
</view>
|
||||
|
||||
<!-- 数量/重量看板 -->
|
||||
<view class="mx-24rpx mb-20rpx rounded-12rpx bg-white shadow-sm overflow-hidden">
|
||||
<view class="px-24rpx py-20rpx border-b border-[#f0f0f0] text-28rpx text-[#333] font-semibold">
|
||||
数量 / 重量看板
|
||||
</view>
|
||||
<view class="p-24rpx">
|
||||
<view class="flex flex-wrap">
|
||||
<view class="w-1/2 mb-16rpx">
|
||||
<text class="text-24rpx text-[#999]">当前批次ID</text>
|
||||
<text class="ml-12rpx text-26rpx text-[#333]">{{ metricPanel.batchId ?? '-' }}</text>
|
||||
</view>
|
||||
<view class="w-1/2 mb-16rpx">
|
||||
<text class="text-24rpx text-[#999]">最近更新</text>
|
||||
<text class="ml-12rpx text-26rpx text-[#333]">{{ metricPanel.updatedAt || '-' }}</text>
|
||||
</view>
|
||||
<view class="w-1/2 mb-16rpx">
|
||||
<text class="text-24rpx text-[#999]">采收数量</text>
|
||||
<text class="ml-12rpx text-26rpx text-[#333]">{{ formatMetric(metricPanel.harvestQuantity, metricPanel.harvestUnit) }}</text>
|
||||
</view>
|
||||
<view class="w-1/2 mb-16rpx">
|
||||
<text class="text-24rpx text-[#999]">分拣称重</text>
|
||||
<text class="ml-12rpx text-26rpx text-[#333]">{{ formatMetric(metricPanel.sortingWeight, 'kg') }}</text>
|
||||
</view>
|
||||
<view class="w-1/2">
|
||||
<text class="text-24rpx text-[#999]">装箱净重</text>
|
||||
<text class="ml-12rpx text-26rpx text-[#333]">{{ formatMetric(metricPanel.packingNetWeight, 'kg') }}</text>
|
||||
</view>
|
||||
<view class="w-1/2">
|
||||
<text class="text-24rpx text-[#999]">发运箱数</text>
|
||||
<text class="ml-12rpx text-26rpx text-[#333]">{{ formatMetric(metricPanel.shipmentBoxCount, '箱') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 扫码按钮 -->
|
||||
<view class="mx-24rpx mb-20rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333]">快捷操作</view>
|
||||
<wd-button size="small" type="info" plain icon="scan" @click="handleScanCode">
|
||||
扫码填充批次ID
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 操作步骤 Tab -->
|
||||
<view class="mx-24rpx mb-20rpx">
|
||||
<wd-tabs v-model="activeTab">
|
||||
<wd-tab title="采收" name="harvest" />
|
||||
<wd-tab title="分拣" name="sorting" />
|
||||
<wd-tab title="装箱" name="packing" />
|
||||
<wd-tab title="入库" name="warehouse" />
|
||||
<wd-tab title="发运" name="shipment" />
|
||||
<wd-tab title="签收" name="sign" />
|
||||
</wd-tabs>
|
||||
</view>
|
||||
|
||||
<!-- 采收表单 -->
|
||||
<view v-show="activeTab === 'harvest'" class="mx-24rpx rounded-12rpx bg-white shadow-sm overflow-hidden">
|
||||
<view class="p-24rpx">
|
||||
<wd-cell-group border>
|
||||
<wd-picker
|
||||
v-model="harvestForm.batchType"
|
||||
label="批次类型"
|
||||
:columns="batchTypeColumns"
|
||||
label-width="200rpx"
|
||||
/>
|
||||
<wd-input v-model="harvestForm.productName" label="产品名称" label-width="200rpx" placeholder="请输入产品名称" />
|
||||
<wd-input v-model="harvestForm.plotName" label="地块名称" label-width="200rpx" placeholder="请输入地块名称" />
|
||||
<wd-input
|
||||
v-model="harvestForm.quantity"
|
||||
label="数量"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入数量"
|
||||
type="number"
|
||||
/>
|
||||
<wd-input v-model="harvestForm.unit" label="单位" label-width="200rpx" placeholder="kg" />
|
||||
</wd-cell-group>
|
||||
<view class="mt-32rpx">
|
||||
<wd-button type="primary" block @click="onHarvest">提交采收</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 分拣表单 -->
|
||||
<view v-show="activeTab === 'sorting'" class="mx-24rpx rounded-12rpx bg-white shadow-sm overflow-hidden">
|
||||
<view class="p-24rpx">
|
||||
<wd-cell-group border>
|
||||
<wd-input
|
||||
v-model="sortingForm.batchId"
|
||||
label="批次ID"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入批次ID"
|
||||
type="number"
|
||||
/>
|
||||
<wd-input
|
||||
v-model="sortingForm.weightResult"
|
||||
label="称重结果"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入称重结果"
|
||||
type="digit"
|
||||
/>
|
||||
<wd-input v-model="sortingForm.unqualifiedCategory" label="不合格分类" label-width="200rpx" placeholder="请输入不合格分类" />
|
||||
</wd-cell-group>
|
||||
<view class="mt-32rpx">
|
||||
<wd-button type="primary" block @click="onSorting">提交分拣</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 装箱表单 -->
|
||||
<view v-show="activeTab === 'packing'" class="mx-24rpx rounded-12rpx bg-white shadow-sm overflow-hidden">
|
||||
<view class="p-24rpx">
|
||||
<wd-cell-group border>
|
||||
<wd-input
|
||||
v-model="packingForm.batchId"
|
||||
label="批次ID"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入批次ID"
|
||||
type="number"
|
||||
/>
|
||||
<wd-input
|
||||
v-model="packingForm.netWeight"
|
||||
label="净重"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入净重"
|
||||
type="digit"
|
||||
/>
|
||||
<wd-input v-model="packingForm.labelCode" label="标签编码" label-width="200rpx" placeholder="请输入标签编码" />
|
||||
</wd-cell-group>
|
||||
<view class="mt-32rpx">
|
||||
<wd-button type="primary" block @click="onPacking">提交装箱</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 入库表单 -->
|
||||
<view v-show="activeTab === 'warehouse'" class="mx-24rpx rounded-12rpx bg-white shadow-sm overflow-hidden">
|
||||
<view class="p-24rpx">
|
||||
<wd-cell-group border>
|
||||
<wd-input
|
||||
v-model="warehouseForm.batchId"
|
||||
label="批次ID"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入批次ID"
|
||||
type="number"
|
||||
/>
|
||||
<wd-picker
|
||||
v-model="warehouseForm.inMode"
|
||||
label="入库模式"
|
||||
:columns="inModeColumns"
|
||||
label-width="200rpx"
|
||||
/>
|
||||
</wd-cell-group>
|
||||
<view class="mt-32rpx">
|
||||
<wd-button type="primary" block @click="onWarehouseIn">提交入库</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 发运表单 -->
|
||||
<view v-show="activeTab === 'shipment'" class="mx-24rpx rounded-12rpx bg-white shadow-sm overflow-hidden">
|
||||
<view class="p-24rpx">
|
||||
<wd-cell-group border>
|
||||
<wd-input
|
||||
v-model="shipmentForm.batchId"
|
||||
label="批次ID"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入批次ID"
|
||||
type="number"
|
||||
/>
|
||||
<wd-input v-model="shipmentForm.vehicleNo" label="车牌号" label-width="200rpx" placeholder="请输入车牌号" />
|
||||
<wd-input
|
||||
v-model="shipmentForm.boxCount"
|
||||
label="箱数"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入箱数"
|
||||
type="number"
|
||||
/>
|
||||
</wd-cell-group>
|
||||
<view class="mt-32rpx">
|
||||
<wd-button type="primary" block @click="onDispatch">提交发运</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 签收表单 -->
|
||||
<view v-show="activeTab === 'sign'" class="mx-24rpx rounded-12rpx bg-white shadow-sm overflow-hidden">
|
||||
<view class="p-24rpx">
|
||||
<wd-cell-group border>
|
||||
<wd-input
|
||||
v-model="signForm.batchId"
|
||||
label="批次ID"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入批次ID"
|
||||
type="number"
|
||||
/>
|
||||
<wd-input v-model="signForm.remark" label="备注" label-width="200rpx" placeholder="请输入备注" />
|
||||
</wd-cell-group>
|
||||
<view class="mt-32rpx">
|
||||
<wd-button type="primary" block @click="onSign">提交签收</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import {
|
||||
dispatchShipment,
|
||||
signShipment,
|
||||
submitHarvest,
|
||||
submitPacking,
|
||||
submitSorting,
|
||||
submitWarehouseIn
|
||||
} from '@/api/agri/biz/flow'
|
||||
import { BATCH_TYPE_OPTIONS, IN_MODE_OPTIONS } from '@/utils/agriTraceDict'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const activeTab = ref('harvest')
|
||||
|
||||
const harvestForm = reactive({
|
||||
batchType: 'HARVEST',
|
||||
productName: '',
|
||||
plotName: '',
|
||||
quantity: '' as string | number,
|
||||
unit: 'kg'
|
||||
})
|
||||
|
||||
const sortingForm = reactive({
|
||||
batchId: '' as string | number,
|
||||
weightResult: '' as string | number,
|
||||
unqualifiedCategory: ''
|
||||
})
|
||||
|
||||
const packingForm = reactive({
|
||||
batchId: '' as string | number,
|
||||
netWeight: '' as string | number,
|
||||
labelCode: ''
|
||||
})
|
||||
|
||||
const warehouseForm = reactive({
|
||||
batchId: '' as string | number,
|
||||
inMode: 'BOX'
|
||||
})
|
||||
|
||||
const shipmentForm = reactive({
|
||||
batchId: '' as string | number,
|
||||
vehicleNo: '',
|
||||
boxCount: '' as string | number
|
||||
})
|
||||
|
||||
const signForm = reactive({
|
||||
batchId: '' as string | number,
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const metricPanel = reactive({
|
||||
batchId: undefined as number | undefined,
|
||||
harvestQuantity: undefined as number | undefined,
|
||||
harvestUnit: 'kg',
|
||||
sortingWeight: undefined as number | undefined,
|
||||
packingNetWeight: undefined as number | undefined,
|
||||
shipmentBoxCount: undefined as number | undefined,
|
||||
updatedAt: ''
|
||||
})
|
||||
|
||||
/** 批次类型下拉列 */
|
||||
const batchTypeColumns = computed(() => [
|
||||
BATCH_TYPE_OPTIONS.map(v => ({ value: v.value, label: v.label }))
|
||||
])
|
||||
|
||||
/** 入库模式下拉列 */
|
||||
const inModeColumns = computed(() => [
|
||||
IN_MODE_OPTIONS.map(v => ({ value: v.value, label: v.label }))
|
||||
])
|
||||
|
||||
const formatMetric = (value?: number, unit?: string) => {
|
||||
if (value === undefined || value === null) {
|
||||
return '-'
|
||||
}
|
||||
return unit ? `${value} ${unit}` : `${value}`
|
||||
}
|
||||
|
||||
const refreshMetricPanel = (patch: Partial<typeof metricPanel>) => {
|
||||
Object.assign(metricPanel, patch, {
|
||||
updatedAt: new Date().toLocaleString()
|
||||
})
|
||||
}
|
||||
|
||||
const syncBatchIdToFollowUpForms = (batchId: number) => {
|
||||
sortingForm.batchId = batchId
|
||||
packingForm.batchId = batchId
|
||||
warehouseForm.batchId = batchId
|
||||
shipmentForm.batchId = batchId
|
||||
signForm.batchId = batchId
|
||||
}
|
||||
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
const onHarvest = async () => {
|
||||
const id = await submitHarvest({
|
||||
...harvestForm,
|
||||
quantity: harvestForm.quantity ? Number(harvestForm.quantity) : undefined
|
||||
})
|
||||
refreshMetricPanel({
|
||||
batchId: id,
|
||||
harvestQuantity: harvestForm.quantity ? Number(harvestForm.quantity) : undefined,
|
||||
harvestUnit: harvestForm.unit || 'kg'
|
||||
})
|
||||
syncBatchIdToFollowUpForms(id)
|
||||
uni.showToast({ title: `采收成功,批次ID:${id}`, icon: 'none' })
|
||||
activeTab.value = 'sorting'
|
||||
}
|
||||
|
||||
const onSorting = async () => {
|
||||
await submitSorting({
|
||||
batchId: Number(sortingForm.batchId),
|
||||
weightResult: sortingForm.weightResult ? Number(sortingForm.weightResult) : undefined,
|
||||
unqualifiedCategory: sortingForm.unqualifiedCategory || undefined
|
||||
})
|
||||
refreshMetricPanel({
|
||||
batchId: Number(sortingForm.batchId),
|
||||
sortingWeight: sortingForm.weightResult ? Number(sortingForm.weightResult) : undefined
|
||||
})
|
||||
uni.showToast({ title: '分拣成功', icon: 'success' })
|
||||
activeTab.value = 'packing'
|
||||
}
|
||||
|
||||
const onPacking = async () => {
|
||||
await submitPacking({
|
||||
batchId: Number(packingForm.batchId),
|
||||
netWeight: packingForm.netWeight ? Number(packingForm.netWeight) : undefined,
|
||||
labelCode: packingForm.labelCode || undefined
|
||||
})
|
||||
refreshMetricPanel({
|
||||
batchId: Number(packingForm.batchId),
|
||||
packingNetWeight: packingForm.netWeight ? Number(packingForm.netWeight) : undefined
|
||||
})
|
||||
uni.showToast({ title: '装箱成功', icon: 'success' })
|
||||
activeTab.value = 'warehouse'
|
||||
}
|
||||
|
||||
const onWarehouseIn = async () => {
|
||||
await submitWarehouseIn({
|
||||
batchId: Number(warehouseForm.batchId),
|
||||
inMode: warehouseForm.inMode || undefined
|
||||
})
|
||||
uni.showToast({ title: '入库成功', icon: 'success' })
|
||||
activeTab.value = 'shipment'
|
||||
}
|
||||
|
||||
const onDispatch = async () => {
|
||||
await dispatchShipment({
|
||||
batchId: Number(shipmentForm.batchId),
|
||||
vehicleNo: shipmentForm.vehicleNo,
|
||||
boxCount: shipmentForm.boxCount ? Number(shipmentForm.boxCount) : undefined
|
||||
})
|
||||
refreshMetricPanel({
|
||||
batchId: Number(shipmentForm.batchId),
|
||||
shipmentBoxCount: shipmentForm.boxCount ? Number(shipmentForm.boxCount) : undefined
|
||||
})
|
||||
uni.showToast({ title: '发运成功', icon: 'success' })
|
||||
activeTab.value = 'sign'
|
||||
}
|
||||
|
||||
const onSign = async () => {
|
||||
await signShipment({
|
||||
batchId: Number(signForm.batchId),
|
||||
remark: signForm.remark || undefined
|
||||
})
|
||||
uni.showToast({ title: '签收成功', icon: 'success' })
|
||||
}
|
||||
|
||||
/** 扫码填充批次ID */
|
||||
const handleScanCode = () => {
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.scanCode({
|
||||
onlyFromCamera: false,
|
||||
scanType: ['qrCode', 'barCode'],
|
||||
success: (res) => {
|
||||
const result = res.result
|
||||
// 尝试解析批次ID(支持纯数字或JSON格式)
|
||||
let batchId: number | undefined
|
||||
try {
|
||||
const parsed = JSON.parse(result)
|
||||
batchId = parsed.batchId || parsed.id
|
||||
} catch {
|
||||
// 如果不是JSON,尝试直接解析为数字
|
||||
const num = Number(result)
|
||||
if (!isNaN(num) && num > 0) {
|
||||
batchId = num
|
||||
}
|
||||
}
|
||||
if (batchId) {
|
||||
syncBatchIdToFollowUpForms(batchId)
|
||||
refreshMetricPanel({ batchId })
|
||||
uni.showToast({ title: `已填充批次ID: ${batchId}`, icon: 'none' })
|
||||
} else {
|
||||
uni.showToast({ title: '无法识别批次ID', icon: 'none' })
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({ title: '扫码取消或失败', icon: 'none' })
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
uni.showToast({ title: '当前环境不支持扫码', icon: 'none' })
|
||||
// #endif
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
334
src/pages-agri/trace-snapshot/index.vue
Normal file
334
src/pages-agri/trace-snapshot/index.vue
Normal file
@@ -0,0 +1,334 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="溯源快照"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<view class="flex items-center px-24rpx">
|
||||
<view class="flex-1" @click="searchVisible = true">
|
||||
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
|
||||
</view>
|
||||
<wd-button size="small" type="primary" icon="scan" class="ml-16rpx" @click="handleScanQuery">
|
||||
扫码
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 快照列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
@click="handleDetail(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:溯源码 + 批次号 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold flex-1 truncate">
|
||||
{{ item.traceCode || '-' }}
|
||||
</view>
|
||||
<view class="text-24rpx text-[#1890ff] ml-12rpx">
|
||||
{{ item.batchNo || '' }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 产品名 + 地块名 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">产品</text>
|
||||
<text>{{ item.productName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">地块</text>
|
||||
<text>{{ item.plotName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 采收信息 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">采收</text>
|
||||
<text>{{ item.harvestOperatorName || '-' }} / {{ formatTime(item.harvestTime) }}</text>
|
||||
</view>
|
||||
<!-- 装箱信息 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">装箱</text>
|
||||
<text>{{ item.packingOperatorName || '-' }} / {{ formatTime(item.packingTime) }}</text>
|
||||
</view>
|
||||
<!-- 入库信息 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">入库</text>
|
||||
<text>{{ item.warehouseOperatorName || '-' }} / {{ formatTime(item.warehouseTime) }}</text>
|
||||
</view>
|
||||
<!-- 发运信息 -->
|
||||
<view class="flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">发运</text>
|
||||
<text>{{ item.shipmentOperatorName || '-' }} / {{ item.vehicleNo || '-' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无溯源快照数据" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">批次号</view>
|
||||
<wd-input v-model="searchForm.batchNo" placeholder="请输入批次号" no-border />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">溯源码</view>
|
||||
<wd-input v-model="searchForm.traceCode" placeholder="请输入溯源码" no-border />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">产品名</view>
|
||||
<wd-input v-model="searchForm.productName" placeholder="请输入产品名称" no-border />
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">重置</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">搜索</wd-button>
|
||||
</view>
|
||||
<view class="mt-20rpx">
|
||||
<wd-button type="info" block plain @click="handleTraceCodeQuery">按溯源码查单条</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
|
||||
<!-- 详情弹窗 -->
|
||||
<wd-popup v-model="detailVisible" position="bottom" custom-style="height: 70%;">
|
||||
<view class="p-24rpx">
|
||||
<view class="text-32rpx text-[#333] font-semibold mb-24rpx">溯源详情</view>
|
||||
<view v-if="currentDetail" class="text-26rpx text-[#666]">
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">ID</text><text>{{ currentDetail.id }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">溯源码</text><text class="flex-1 break-all">{{ currentDetail.traceCode }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">批次号</text><text>{{ currentDetail.batchNo }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">产品名</text><text>{{ currentDetail.productName || '-' }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">地块名</text><text>{{ currentDetail.plotName || '-' }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">采收操作人</text><text>{{ currentDetail.harvestOperatorName || '-' }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">采收时间</text><text>{{ formatTime(currentDetail.harvestTime) }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">装箱操作人</text><text>{{ currentDetail.packingOperatorName || '-' }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">装箱时间</text><text>{{ formatTime(currentDetail.packingTime) }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">入库操作人</text><text>{{ currentDetail.warehouseOperatorName || '-' }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">入库时间</text><text>{{ formatTime(currentDetail.warehouseTime) }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">发运操作人</text><text>{{ currentDetail.shipmentOperatorName || '-' }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">发运时间</text><text>{{ formatTime(currentDetail.shipmentTime) }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">车牌号</text><text>{{ currentDetail.vehicleNo || '-' }}</text></view>
|
||||
</view>
|
||||
<wd-button type="primary" block class="mt-32rpx" @click="detailVisible = false">关闭</wd-button>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { AgriTraceSnapshotVO } from '@/api/agri/trace/snapshot'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import {
|
||||
getAgriTraceSnapshotByTraceCode,
|
||||
getAgriTraceSnapshotPage
|
||||
} from '@/api/agri/trace/snapshot'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const total = ref(0)
|
||||
const list = ref<AgriTraceSnapshotVO[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
batchNo: '',
|
||||
traceCode: '',
|
||||
productName: ''
|
||||
})
|
||||
|
||||
// 详情弹窗
|
||||
const detailVisible = ref(false)
|
||||
const currentDetail = ref<AgriTraceSnapshotVO | null>(null)
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.batchNo) conditions.push(`批次:${searchForm.batchNo}`)
|
||||
if (searchForm.traceCode) conditions.push(`溯源码:${searchForm.traceCode}`)
|
||||
if (searchForm.productName) conditions.push(`产品:${searchForm.productName}`)
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索溯源快照'
|
||||
})
|
||||
|
||||
/** 格式化时间 */
|
||||
function formatTime(time?: string | number) {
|
||||
if (!time) return '-'
|
||||
// 如果是时间戳(数字),转换为日期字符串
|
||||
if (typeof time === 'number') {
|
||||
const date = new Date(time)
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
const hours = String(date.getHours()).padStart(2, '0')
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}`
|
||||
}
|
||||
// 如果是字符串,处理 ISO 格式
|
||||
if (typeof time === 'string') {
|
||||
return time.replace('T', ' ').substring(0, 16)
|
||||
}
|
||||
return '-'
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params: Record<string, any> = { ...queryParams.value }
|
||||
if (searchForm.batchNo) params.batchNo = searchForm.batchNo
|
||||
if (searchForm.traceCode) params.traceCode = searchForm.traceCode
|
||||
if (searchForm.productName) params.productName = searchForm.productName
|
||||
const data = await getAgriTraceSnapshotPage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
searchVisible.value = false
|
||||
queryParams.value = {
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.batchNo = ''
|
||||
searchForm.traceCode = ''
|
||||
searchForm.productName = ''
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10 }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 按溯源码查单条 */
|
||||
async function handleTraceCodeQuery() {
|
||||
if (!searchForm.traceCode) {
|
||||
uni.showToast({ title: '请先输入溯源码', icon: 'none' })
|
||||
return
|
||||
}
|
||||
searchVisible.value = false
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const data = await getAgriTraceSnapshotByTraceCode(searchForm.traceCode)
|
||||
list.value = data ? [data] : []
|
||||
total.value = list.value.length
|
||||
loadMoreState.value = 'finished'
|
||||
} catch {
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 查看详情 */
|
||||
function handleDetail(item: AgriTraceSnapshotVO) {
|
||||
currentDetail.value = item
|
||||
detailVisible.value = true
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 扫码查询 */
|
||||
function handleScanQuery() {
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.scanCode({
|
||||
onlyFromCamera: false,
|
||||
scanType: ['qrCode', 'barCode'],
|
||||
success: async (res) => {
|
||||
const result = res.result
|
||||
// 尝试解析溯源码(支持纯字符串或JSON格式)
|
||||
let traceCode: string | undefined
|
||||
try {
|
||||
const parsed = JSON.parse(result)
|
||||
traceCode = parsed.traceCode || parsed.code
|
||||
} catch {
|
||||
// 如果不是JSON,直接使用扫码结果
|
||||
traceCode = result
|
||||
}
|
||||
if (traceCode) {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const data = await getAgriTraceSnapshotByTraceCode(traceCode)
|
||||
list.value = data ? [data] : []
|
||||
total.value = list.value.length
|
||||
loadMoreState.value = 'finished'
|
||||
if (data) {
|
||||
uni.showToast({ title: '查询成功', icon: 'success' })
|
||||
} else {
|
||||
uni.showToast({ title: '未找到该溯源码', icon: 'none' })
|
||||
}
|
||||
} catch {
|
||||
loadMoreState.value = 'error'
|
||||
uni.showToast({ title: '查询失败', icon: 'none' })
|
||||
}
|
||||
} else {
|
||||
uni.showToast({ title: '无法识别溯源码', icon: 'none' })
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({ title: '扫码取消或失败', icon: 'none' })
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
uni.showToast({ title: '当前环境不支持扫码', icon: 'none' })
|
||||
// #endif
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
298
src/pages-erp/farmer/form/index.vue
Normal file
298
src/pages-erp/farmer/form/index.vue
Normal file
@@ -0,0 +1,298 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-input
|
||||
v-model="formData.name"
|
||||
label="户主姓名"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入户主姓名"
|
||||
prop="name"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.idCardNumber"
|
||||
label="身份证号"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入身份证号"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.mobile"
|
||||
label="手机号码"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入手机号码"
|
||||
type="number"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.address"
|
||||
label="住址"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入住址"
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-cell-group title="种植信息" border>
|
||||
<wd-input
|
||||
v-model="formData.plantingBase"
|
||||
label="种植基地"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入所属种植基地"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.contractNumber"
|
||||
label="合同号"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入合同号"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.contractedArea"
|
||||
label="签订面积"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入签订面积"
|
||||
type="number"
|
||||
suffix-icon="亩"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.orderQuantity"
|
||||
label="订购数量"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入订购数量"
|
||||
type="number"
|
||||
suffix-icon="株"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.actualArea"
|
||||
label="实种面积"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入实种面积"
|
||||
type="number"
|
||||
suffix-icon="亩"
|
||||
clearable
|
||||
/>
|
||||
<wd-cell title="移栽时间" title-width="180rpx" center>
|
||||
<wd-datetime-picker
|
||||
v-model="formData.transplantTime"
|
||||
type="date"
|
||||
label=""
|
||||
placeholder="请选择移栽时间"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-input
|
||||
v-model="formData.transplantQuantity"
|
||||
label="移栽数量"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入移栽数量"
|
||||
type="number"
|
||||
suffix-icon="盘"
|
||||
clearable
|
||||
/>
|
||||
<wd-cell title="成熟时间" title-width="180rpx" center>
|
||||
<wd-datetime-picker
|
||||
v-model="formData.maturityTime"
|
||||
type="date"
|
||||
label=""
|
||||
placeholder="请选择成熟时间"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="预计采收" title-width="180rpx" center>
|
||||
<wd-datetime-picker
|
||||
v-model="formData.expectedHarvestTime"
|
||||
type="date"
|
||||
label=""
|
||||
placeholder="请选择预计采收时间"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="使用品种" title-width="180rpx" center>
|
||||
<wd-picker
|
||||
v-model="formData.usedVariety"
|
||||
:columns="varietyColumns"
|
||||
label=""
|
||||
placeholder="请选择使用品种"
|
||||
@confirm="onVarietyConfirm"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-input
|
||||
v-model="formData.plantingMethod"
|
||||
label="种植方式"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入种植方式"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.adminName"
|
||||
label="管理员"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入管理员姓名"
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-cell-group title="其他信息" border>
|
||||
<wd-cell title="开启状态" title-width="180rpx" center>
|
||||
<wd-switch v-model="statusEnabled" />
|
||||
</wd-cell>
|
||||
<wd-input
|
||||
v-model="formData.sort"
|
||||
label="排序"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入排序"
|
||||
type="number"
|
||||
clearable
|
||||
/>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { Farmer } from '@/api/erp/farmer'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createFarmer, getFarmer, updateFarmer, VARIETY_OPTIONS } from '@/api/erp/farmer'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const toast = useToast()
|
||||
const getTitle = computed(() => props.id ? '编辑农户' : '新增农户')
|
||||
const formLoading = ref(false)
|
||||
const formData = ref<Farmer>({
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
idCardNumber: undefined,
|
||||
mobile: undefined,
|
||||
address: undefined,
|
||||
plantingBase: undefined,
|
||||
contractNumber: undefined,
|
||||
contractedArea: undefined,
|
||||
orderQuantity: undefined,
|
||||
actualArea: undefined,
|
||||
transplantTime: undefined,
|
||||
transplantQuantity: undefined,
|
||||
maturityTime: undefined,
|
||||
expectedHarvestTime: undefined,
|
||||
usedVariety: undefined,
|
||||
plantingMethod: undefined,
|
||||
adminName: undefined,
|
||||
remark: undefined,
|
||||
status: 0,
|
||||
sort: 0,
|
||||
})
|
||||
const formRules = {
|
||||
name: [{ required: true, message: '户主姓名不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 状态开关
|
||||
const statusEnabled = ref(true)
|
||||
watch(statusEnabled, (val) => {
|
||||
formData.value.status = val ? 0 : 1
|
||||
})
|
||||
watch(() => formData.value.status, (val) => {
|
||||
statusEnabled.value = val === 0
|
||||
})
|
||||
|
||||
/** 品种下拉列 */
|
||||
const varietyColumns = computed(() => [
|
||||
VARIETY_OPTIONS.map(v => ({ value: v.value, label: v.label })),
|
||||
])
|
||||
|
||||
/** 品种选择回调 */
|
||||
function onVarietyConfirm({ value }: any) {
|
||||
formData.value.usedVariety = value?.[0]
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/farmer/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getFarmer(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
if (props.id) {
|
||||
await updateFarmer(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createFarmer(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
289
src/pages-erp/farmer/index.vue
Normal file
289
src/pages-erp/farmer/index.vue
Normal file
@@ -0,0 +1,289 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="农户管理"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<view @click="searchVisible = true">
|
||||
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 农户列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
@click="handleEdit(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:姓名 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.name || '-' }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="item.status === 0 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff1f0] text-[#f5222d]'"
|
||||
>
|
||||
{{ item.status === 0 ? '正常' : '停用' }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 住址 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">住址</text>
|
||||
<text>{{ item.address || '-' }}</text>
|
||||
</view>
|
||||
<!-- 种植基地 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">种植基地</text>
|
||||
<text>{{ item.plantingBase || '-' }}</text>
|
||||
</view>
|
||||
<!-- 合同号 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">合同号</text>
|
||||
<text>{{ item.contractNumber || '-' }}</text>
|
||||
</view>
|
||||
<!-- 使用品种 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">使用品种</text>
|
||||
<text>{{ item.usedVariety || '-' }}</text>
|
||||
</view>
|
||||
<!-- 管理员 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">管理员</text>
|
||||
<text>{{ item.adminName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#333] font-semibold">{{ item.contractedArea ?? '-' }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">签订面积</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#333] font-semibold">{{ item.actualArea ?? '-' }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">实种面积</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#1890ff] font-semibold">{{ item.orderQuantity ?? '-' }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">订购数量</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:farmer:update'])"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:farmer:delete'])"
|
||||
size="small" type="error" plain @click="handleDelete(item.id!)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无农户数据" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 新增按钮 -->
|
||||
<wd-fab
|
||||
v-if="hasAccessByCodes(['erp:farmer:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">户主姓名</view>
|
||||
<wd-input v-model="searchForm.name" placeholder="请输入户主姓名" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">种植基地</view>
|
||||
<wd-input v-model="searchForm.plantingBase" placeholder="请输入种植基地" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">使用品种</view>
|
||||
<wd-picker
|
||||
v-model="searchForm.usedVariety"
|
||||
:columns="varietyColumns"
|
||||
placeholder="请选择使用品种"
|
||||
@confirm="onVarietyConfirm"
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">重置</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">搜索</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { Farmer } from '@/api/erp/farmer'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteFarmer, getFarmerPage, VARIETY_OPTIONS } from '@/api/erp/farmer'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<Farmer[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
name: undefined as string | undefined,
|
||||
plantingBase: undefined as string | undefined,
|
||||
usedVariety: undefined as string | undefined,
|
||||
})
|
||||
|
||||
/** 品种下拉列 */
|
||||
const varietyColumns = computed(() => [
|
||||
[{ value: '', label: '全部' }, ...VARIETY_OPTIONS.map(v => ({ value: v.value, label: v.label }))],
|
||||
])
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.name) conditions.push(`姓名:${searchForm.name}`)
|
||||
if (searchForm.plantingBase) conditions.push(`基地:${searchForm.plantingBase}`)
|
||||
if (searchForm.usedVariety) conditions.push(`品种:${searchForm.usedVariety}`)
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索农户'
|
||||
})
|
||||
|
||||
/** 品种选择回调 */
|
||||
function onVarietyConfirm({ value }: any) {
|
||||
searchForm.usedVariety = value?.[0] || undefined
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询农户列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
const data = await getFarmerPage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
searchVisible.value = false
|
||||
queryParams.value = {
|
||||
...searchForm,
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.name = undefined
|
||||
searchForm.plantingBase = undefined
|
||||
searchForm.usedVariety = undefined
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10 }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 新增农户 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/farmer/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: Farmer) {
|
||||
uni.navigateTo({ url: `/pages-erp/farmer/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该农户吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteFarmer(id)
|
||||
toast.success('删除成功')
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
126
src/pages-erp/pick-broccoli/components/search-form.vue
Normal file
126
src/pages-erp/pick-broccoli/components/search-form.vue
Normal file
@@ -0,0 +1,126 @@
|
||||
<template>
|
||||
<!-- 搜索框入口 -->
|
||||
<view @click="visible = true">
|
||||
<wd-search :placeholder="placeholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="visible" position="top" @close="visible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">
|
||||
采摘编号
|
||||
</view>
|
||||
<wd-input
|
||||
v-model="formData.pickCode"
|
||||
placeholder="请输入采摘编号"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">
|
||||
采摘人员
|
||||
</view>
|
||||
<wd-input
|
||||
v-model="formData.userName"
|
||||
placeholder="请输入采摘人员姓名"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">
|
||||
状态
|
||||
</view>
|
||||
<wd-radio-group v-model="formData.status" shape="button">
|
||||
<wd-radio :value="-1">
|
||||
全部
|
||||
</wd-radio>
|
||||
<wd-radio :value="1">
|
||||
已采摘
|
||||
</wd-radio>
|
||||
<wd-radio :value="2">
|
||||
已装框
|
||||
</wd-radio>
|
||||
<wd-radio :value="3">
|
||||
已装车
|
||||
</wd-radio>
|
||||
<wd-radio :value="4">
|
||||
已入库
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">
|
||||
重置
|
||||
</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">
|
||||
搜索
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { getNavbarHeight } from '@/utils'
|
||||
|
||||
const emit = defineEmits<{
|
||||
search: [data: Record<string, any>]
|
||||
reset: []
|
||||
}>()
|
||||
|
||||
const visible = ref(false)
|
||||
const formData = reactive({
|
||||
pickCode: undefined as string | undefined,
|
||||
userName: undefined as string | undefined,
|
||||
status: -1,
|
||||
})
|
||||
|
||||
const statusMap: Record<number, string> = {
|
||||
1: '已采摘',
|
||||
2: '已装框',
|
||||
3: '已装车',
|
||||
4: '已入库',
|
||||
}
|
||||
|
||||
/** 搜索条件 placeholder 拼接 */
|
||||
const placeholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (formData.pickCode) {
|
||||
conditions.push(`编号:${formData.pickCode}`)
|
||||
}
|
||||
if (formData.userName) {
|
||||
conditions.push(`人员:${formData.userName}`)
|
||||
}
|
||||
if (formData.status !== -1) {
|
||||
conditions.push(`状态:${statusMap[formData.status] || formData.status}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索采摘记录'
|
||||
})
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
visible.value = false
|
||||
const params: Record<string, any> = {}
|
||||
if (formData.pickCode) {
|
||||
params.pickCode = formData.pickCode
|
||||
}
|
||||
if (formData.userName) {
|
||||
params.userName = formData.userName
|
||||
}
|
||||
if (formData.status !== -1) {
|
||||
params.status = formData.status
|
||||
}
|
||||
emit('search', params)
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
formData.pickCode = undefined
|
||||
formData.userName = undefined
|
||||
formData.status = -1
|
||||
visible.value = false
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
237
src/pages-erp/pick-broccoli/detail/index.vue
Normal file
237
src/pages-erp/pick-broccoli/detail/index.vue
Normal file
@@ -0,0 +1,237 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采摘记录详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view v-if="formData">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="采摘编号" :value="formData.pickCode" />
|
||||
<wd-cell title="状态">
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getStatusClass(formData.status)"
|
||||
>
|
||||
{{ getStatusText(formData.status) }}
|
||||
</view>
|
||||
</wd-cell>
|
||||
<wd-cell title="关联产品" :value="formData.productName || '-'" />
|
||||
<wd-cell title="采摘人员" :value="formData.userName || '-'" />
|
||||
<wd-cell title="田间编号" :value="formData.fieldCode || '-'" />
|
||||
<wd-cell title="采摘时间" :value="formatDate(formData.pickTime)" />
|
||||
<wd-cell title="创建时间" :value="formatDate(formData.createTime)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 采摘信息 -->
|
||||
<wd-cell-group title="采摘信息" border>
|
||||
<wd-cell title="框编号" :value="formData.basketCode || '-'" />
|
||||
<wd-cell title="每筐重量" :value="formData.basketWeight ? `${formData.basketWeight} kg` : '-'" />
|
||||
<wd-cell title="车牌号" :value="formData.licensePlate || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 装车信息 (status >= 3) -->
|
||||
<wd-cell-group v-if="(formData.status ?? 0) >= 3" title="装车信息" border>
|
||||
<wd-cell title="装车人员" :value="formData.loaderName || '-'" />
|
||||
<wd-cell title="装车时间" :value="formatDate(formData.loadTime)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 卸车入库信息 (status === 4) -->
|
||||
<wd-cell-group v-if="formData.status === 4" title="卸车入库信息" border>
|
||||
<wd-cell title="卸车人员" :value="formData.unloaderName || '-'" />
|
||||
<wd-cell title="卸车时间" :value="formatDate(formData.unloadTime)" />
|
||||
<wd-cell title="入库仓库" :value="formData.warehouseName || '-'" />
|
||||
<wd-cell title="卸车批次号" :value="formData.unloadBatch || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 备注 -->
|
||||
<wd-cell-group v-if="formData.remark" title="备注" border>
|
||||
<wd-cell :value="formData.remark" />
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<view class="yd-detail-footer-actions">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && (formData?.status ?? 0) < 3"
|
||||
class="flex-1" type="primary" @click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && formData?.status === 1"
|
||||
class="flex-1" type="success" @click="handleStatusUpdate(2, '装框')"
|
||||
>
|
||||
装框
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && formData?.status === 2"
|
||||
class="flex-1" type="warning" @click="handleLoadTruck"
|
||||
>
|
||||
装车
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:delete']) && (formData?.status ?? 0) < 3"
|
||||
class="flex-1" type="error" :loading="deleting" @click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PickBroccoli } from '@/api/erp/pick-broccoli'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deletePickBroccoli, getPickBroccoli, loadTruck, updatePickBroccoliStatus } from '@/api/erp/pick-broccoli'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const formData = ref<PickBroccoli>()
|
||||
const deleting = ref(false)
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(date?: string) {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleString('zh-CN')
|
||||
}
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number) {
|
||||
switch (status) {
|
||||
case 1: return '已采摘'
|
||||
case 2: return '已装框'
|
||||
case 3: return '已装车'
|
||||
case 4: return '已卸车入库'
|
||||
default: return '未知'
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number) {
|
||||
switch (status) {
|
||||
case 1: return 'bg-[#e6f7ff] text-[#1890ff]'
|
||||
case 2: return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
case 3: return 'bg-[#f9f0ff] text-[#722ed1]'
|
||||
case 4: return 'bg-[#f6ffed] text-[#52c41a]'
|
||||
default: return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/pick-broccoli/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getPickBroccoli(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/pick-broccoli/form/index?id=${props.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 状态更新(装框) */
|
||||
function handleStatusUpdate(status: number, text: string) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `确认将该记录状态更新为"${text}完成"吗?`,
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePickBroccoliStatus(props.id, status)
|
||||
toast.success(`${text}操作成功`)
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 装车操作 */
|
||||
function handleLoadTruck() {
|
||||
uni.showModal({
|
||||
title: '装车',
|
||||
content: '请输入车牌号',
|
||||
editable: true,
|
||||
placeholderText: '车牌号',
|
||||
success: async (res) => {
|
||||
if (!res.confirm || !res.content) return
|
||||
try {
|
||||
await loadTruck(props.id, res.content, 0, '')
|
||||
toast.success('装车操作成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该采摘记录吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
deleting.value = true
|
||||
try {
|
||||
await deletePickBroccoli(props.id)
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
354
src/pages-erp/pick-broccoli/form/index.vue
Normal file
354
src/pages-erp/pick-broccoli/form/index.vue
Normal file
@@ -0,0 +1,354 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-input
|
||||
v-model="formData.pickCode"
|
||||
label="采摘编号"
|
||||
label-width="180rpx"
|
||||
prop="pickCode"
|
||||
placeholder="自动生成"
|
||||
:disabled="isLoaded"
|
||||
readonly
|
||||
>
|
||||
<template v-if="!props.id" #suffix>
|
||||
<wd-button size="small" type="primary" @click="handleGenerateCode">
|
||||
生成
|
||||
</wd-button>
|
||||
</template>
|
||||
</wd-input>
|
||||
<wd-cell title="采摘人员" title-width="180rpx" prop="userName" center>
|
||||
<wd-picker
|
||||
v-model="formData.userId"
|
||||
:columns="userColumns"
|
||||
label=""
|
||||
placeholder="请选择采摘人员"
|
||||
:disabled="isLoaded"
|
||||
@confirm="onUserConfirm"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="关联产品" title-width="180rpx" prop="productName" center>
|
||||
<wd-picker
|
||||
v-model="formData.productId"
|
||||
:columns="productColumns"
|
||||
label=""
|
||||
placeholder="请选择产品"
|
||||
:disabled="isLoaded"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="田间编号" title-width="180rpx" prop="fieldCode" center>
|
||||
<wd-picker
|
||||
v-model="formData.fieldCode"
|
||||
:columns="fieldColumns"
|
||||
label=""
|
||||
placeholder="请选择田间编号"
|
||||
:disabled="isLoaded"
|
||||
/>
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 采摘信息 -->
|
||||
<wd-cell-group title="采摘信息" border>
|
||||
<wd-cell title="框编号" title-width="180rpx" prop="basketCode" center>
|
||||
<wd-picker
|
||||
v-model="formData.basketCode"
|
||||
:columns="basketColumns"
|
||||
label=""
|
||||
placeholder="请选择框编号"
|
||||
:disabled="isLoaded"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-input
|
||||
v-model="formData.basketWeight"
|
||||
label="每筐重量(kg)"
|
||||
label-width="180rpx"
|
||||
type="number"
|
||||
placeholder="请输入每筐重量"
|
||||
clearable
|
||||
:disabled="isLoaded"
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.licensePlate"
|
||||
label="车牌号"
|
||||
label-width="180rpx"
|
||||
clearable
|
||||
placeholder="请输入车牌号"
|
||||
:disabled="isLoaded"
|
||||
/>
|
||||
<wd-cell title="采摘时间" title-width="180rpx" prop="pickTime" center>
|
||||
<wd-datetime-picker
|
||||
v-model="formData.pickTime"
|
||||
type="datetime"
|
||||
label=""
|
||||
placeholder="请选择采摘时间"
|
||||
:disabled="isLoaded"
|
||||
/>
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 状态信息(编辑时) -->
|
||||
<wd-cell-group v-if="formData.id" title="状态信息" border>
|
||||
<wd-cell title="当前状态" :value="getStatusText(formData.status)" />
|
||||
<wd-cell v-if="formData.loadTime" title="装车时间" :value="formatDate(formData.loadTime)" />
|
||||
<wd-cell v-if="formData.loaderName" title="装车人" :value="formData.loaderName" />
|
||||
<wd-cell v-if="formData.unloadTime" title="卸车时间" :value="formatDate(formData.unloadTime)" />
|
||||
<wd-cell v-if="formData.unloaderName" title="卸车人员" :value="formData.unloaderName" />
|
||||
<wd-cell v-if="formData.warehouseName" title="仓库名称" :value="formData.warehouseName" />
|
||||
<wd-cell v-if="formData.unloadBatch" title="卸车批次号" :value="formData.unloadBatch" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 备注 -->
|
||||
<wd-cell-group title="其他" border>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注信息(可选)"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
:disabled="isLoaded"
|
||||
/>
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
:disabled="isLoaded"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { PickBroccoli } from '@/api/erp/pick-broccoli'
|
||||
import type { User } from '@/api/system/user'
|
||||
import type { ProductSimple } from '@/api/erp/product'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createPickBroccoli, generatePickCode, getPickBroccoli, updatePickBroccoli } from '@/api/erp/pick-broccoli'
|
||||
import { getSimpleUserList } from '@/api/system/user'
|
||||
import { getProductSimpleList } from '@/api/erp/product'
|
||||
import { getFarmingManagementPage } from '@/api/erp/farming'
|
||||
import { getBoxPage } from '@/api/erp/box'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const toast = useToast()
|
||||
const getTitle = computed(() => props.id ? '编辑采摘记录' : '新增采摘记录')
|
||||
const formLoading = ref(false)
|
||||
const formData = ref<PickBroccoli>({
|
||||
id: undefined,
|
||||
pickCode: '',
|
||||
userId: undefined,
|
||||
userName: '',
|
||||
productId: undefined,
|
||||
productName: '',
|
||||
fieldCode: '',
|
||||
basketCode: '',
|
||||
basketWeight: undefined,
|
||||
licensePlate: '',
|
||||
pickTime: undefined,
|
||||
status: 1,
|
||||
remark: '',
|
||||
})
|
||||
const formRules = {
|
||||
pickCode: [{ required: true, message: '采摘编号不能为空' }],
|
||||
userName: [{ required: true, message: '采摘人员不能为空' }],
|
||||
productName: [{ required: true, message: '关联产品不能为空' }],
|
||||
fieldCode: [{ required: true, message: '田间编号不能为空' }],
|
||||
basketCode: [{ required: true, message: '框编号不能为空' }],
|
||||
pickTime: [{ required: true, message: '采摘时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
const userList = ref<User[]>([])
|
||||
const productList = ref<ProductSimple[]>([])
|
||||
const fieldList = ref<string[]>([])
|
||||
const basketList = ref<string[]>([])
|
||||
|
||||
/** 采摘人员下拉列 */
|
||||
const userColumns = computed(() => [
|
||||
userList.value.map(u => ({ value: u.id, label: u.nickname })),
|
||||
])
|
||||
|
||||
/** 产品下拉列 */
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(p => ({ value: p.id, label: p.name })),
|
||||
])
|
||||
|
||||
/** 田间编号下拉列 */
|
||||
const fieldColumns = computed(() => [
|
||||
fieldList.value.map(code => ({ value: code, label: code })),
|
||||
])
|
||||
|
||||
/** 框编号下拉列 */
|
||||
const basketColumns = computed(() => [
|
||||
basketList.value.map(code => ({ value: code, label: code })),
|
||||
])
|
||||
|
||||
/** 采摘人员选择回调 */
|
||||
function onUserConfirm({ value }: any) {
|
||||
const userId = value?.[0]
|
||||
formData.value.userId = userId
|
||||
const user = userList.value.find(u => u.id === userId)
|
||||
if (user) {
|
||||
formData.value.userName = user.nickname
|
||||
}
|
||||
}
|
||||
|
||||
/** 产品选择回调 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
const productId = value?.[0]
|
||||
formData.value.productId = productId
|
||||
const product = productList.value.find(p => p.id === productId)
|
||||
if (product) {
|
||||
formData.value.productName = product.name
|
||||
}
|
||||
}
|
||||
|
||||
/** 加载下拉列表数据 */
|
||||
async function loadDropdownData() {
|
||||
try {
|
||||
const [users, products, farmingResult, boxResult] = await Promise.all([
|
||||
getSimpleUserList(),
|
||||
getProductSimpleList(),
|
||||
getFarmingManagementPage(),
|
||||
getBoxPage(),
|
||||
])
|
||||
userList.value = users || []
|
||||
productList.value = products || []
|
||||
// 提取田间编号
|
||||
const farmingList = farmingResult?.list || []
|
||||
fieldList.value = [...new Set(farmingList.filter(f => f.code?.trim()).map(f => f.code))]
|
||||
// 提取框编号
|
||||
const boxList = boxResult?.list || []
|
||||
basketList.value = boxList.filter(b => b.boxNumber?.trim()).map(b => b.boxNumber)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
}
|
||||
|
||||
/** 已装车状态时禁用所有字段 */
|
||||
const isLoaded = computed(() => (formData.value.status ?? 0) >= 3)
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(date?: string) {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleString('zh-CN')
|
||||
}
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number) {
|
||||
switch (status) {
|
||||
case 1: return '已采摘'
|
||||
case 2: return '已装框'
|
||||
case 3: return '已装车'
|
||||
case 4: return '已卸车入库'
|
||||
default: return '未知'
|
||||
}
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/pick-broccoli/index')
|
||||
}
|
||||
|
||||
/** 生成采摘编号 */
|
||||
async function handleGenerateCode() {
|
||||
try {
|
||||
const data = await generatePickCode()
|
||||
if (data && data.code) {
|
||||
formData.value.pickCode = data.code
|
||||
} else {
|
||||
// 前端生成备用编号
|
||||
const d = new Date()
|
||||
const y = d.getFullYear()
|
||||
const m = String(d.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(d.getDate()).padStart(2, '0')
|
||||
const rnd = Math.floor(Math.random() * 1000000).toString().padStart(6, '0')
|
||||
formData.value.pickCode = `CJXL${y}${m}${day}${rnd}`
|
||||
}
|
||||
} catch {
|
||||
// 前端生成备用编号
|
||||
const d = new Date()
|
||||
const y = d.getFullYear()
|
||||
const m = String(d.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(d.getDate()).padStart(2, '0')
|
||||
const rnd = Math.floor(Math.random() * 1000000).toString().padStart(6, '0')
|
||||
formData.value.pickCode = `CJXL${y}${m}${day}${rnd}`
|
||||
}
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) {
|
||||
// 新增时自动生成编号
|
||||
await handleGenerateCode()
|
||||
return
|
||||
}
|
||||
formData.value = await getPickBroccoli(props.id)
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) {
|
||||
return
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
if (props.id) {
|
||||
await updatePickBroccoli(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createPickBroccoli(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
await loadDropdownData()
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
331
src/pages-erp/pick-broccoli/index.vue
Normal file
331
src/pages-erp/pick-broccoli/index.vue
Normal file
@@ -0,0 +1,331 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采摘管理"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<SearchForm @search="handleQuery" @reset="handleReset" />
|
||||
|
||||
<!-- 采摘记录列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
@click="handleCardClick(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:采摘编号 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.pickCode }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getStatusClass(item.status)"
|
||||
>
|
||||
{{ getStatusText(item.status) }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 产品 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">产品</text>
|
||||
<text>{{ item.productName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 采摘人员 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">采摘人员</text>
|
||||
<text>{{ item.userName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 田间编号 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">田间编号</text>
|
||||
<text>{{ item.fieldCode || '-' }}</text>
|
||||
</view>
|
||||
<!-- 框编号 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">框编号</text>
|
||||
<text>{{ item.basketCode || '-' }}</text>
|
||||
</view>
|
||||
<!-- 重量 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">重量</text>
|
||||
<text class="font-semibold">{{ item.basketWeight || 0 }} kg</text>
|
||||
</view>
|
||||
<!-- 车牌号 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">车牌号</text>
|
||||
<text>{{ item.licensePlate || '-' }}</text>
|
||||
</view>
|
||||
<!-- 采摘时间 -->
|
||||
<view class="flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">采摘时间</text>
|
||||
<text>{{ formatDate(item.pickTime) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && (item.status ?? 0) < 3"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:query'])"
|
||||
size="small" plain @click="handleDetail(item)"
|
||||
>
|
||||
详情
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && item.status === 1"
|
||||
size="small" type="success" plain @click="handleStatusUpdate(item, 2, '装框')"
|
||||
>
|
||||
装框
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && item.status === 2"
|
||||
size="small" type="warning" plain @click="handleLoadTruck(item)"
|
||||
>
|
||||
装车
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:delete']) && (item.status ?? 0) < 3"
|
||||
size="small" type="error" plain @click="handleDelete(item.id!)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无采摘记录数据" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 新增按钮 -->
|
||||
<wd-fab
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PickBroccoli } from '@/api/erp/pick-broccoli'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deletePickBroccoli, getPickBroccoliPage, loadTruck, updatePickBroccoliStatus } from '@/api/erp/pick-broccoli'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
import SearchForm from './components/search-form.vue'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<PickBroccoli[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(date?: string) {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleString('zh-CN')
|
||||
}
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number) {
|
||||
switch (status) {
|
||||
case 1: return '已采摘'
|
||||
case 2: return '已装框'
|
||||
case 3: return '已装车'
|
||||
case 4: return '已入库'
|
||||
default: return '未知'
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number) {
|
||||
switch (status) {
|
||||
case 1: return 'bg-[#e6f7ff] text-[#1890ff]'
|
||||
case 2: return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
case 3: return 'bg-[#f9f0ff] text-[#722ed1]'
|
||||
case 4: return 'bg-[#f6ffed] text-[#52c41a]'
|
||||
default: return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询采摘记录列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
const data = await getPickBroccoliPage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery(data?: Record<string, any>) {
|
||||
queryParams.value = {
|
||||
...data,
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function handleReset() {
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') {
|
||||
return
|
||||
}
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 刷新列表 */
|
||||
function refreshList() {
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 卡片点击 — 打开详情 */
|
||||
function handleCardClick(item: PickBroccoli) {
|
||||
handleDetail(item)
|
||||
}
|
||||
|
||||
/** 新增采摘记录 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({
|
||||
url: '/pages-erp/pick-broccoli/form/index',
|
||||
})
|
||||
}
|
||||
|
||||
/** 查看详情 */
|
||||
function handleDetail(item: PickBroccoli) {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/pick-broccoli/detail/index?id=${item.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: PickBroccoli) {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/pick-broccoli/form/index?id=${item.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 状态更新(装框) */
|
||||
function handleStatusUpdate(item: PickBroccoli, status: number, text: string) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `确认将该记录状态更新为"${text}完成"吗?`,
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePickBroccoliStatus(item.id!, status)
|
||||
toast.success(`${text}操作成功`)
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 装车操作 — 简易输入车牌号 + 装车人 */
|
||||
function handleLoadTruck(item: PickBroccoli) {
|
||||
// 小程序端用简化方式:直接输入车牌号
|
||||
uni.showModal({
|
||||
title: '装车',
|
||||
content: '请输入车牌号',
|
||||
editable: true,
|
||||
placeholderText: '车牌号',
|
||||
success: async (res) => {
|
||||
if (!res.confirm || !res.content) return
|
||||
try {
|
||||
// 使用当前用户作为装车人(简化处理)
|
||||
await loadTruck(item.id!, res.content, 0, '')
|
||||
toast.success('装车操作成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该采摘记录吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deletePickBroccoli(id)
|
||||
toast.success('删除成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
104
src/pages-erp/purchase-in/components/search-form.vue
Normal file
104
src/pages-erp/purchase-in/components/search-form.vue
Normal file
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<!-- 搜索框入口 -->
|
||||
<view @click="visible = true">
|
||||
<wd-search :placeholder="placeholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="visible" position="top" @close="visible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">
|
||||
入库单编号
|
||||
</view>
|
||||
<wd-input
|
||||
v-model="formData.no"
|
||||
placeholder="请输入入库单编号"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">
|
||||
审核状态
|
||||
</view>
|
||||
<wd-radio-group v-model="formData.status" shape="button">
|
||||
<wd-radio :value="-1">
|
||||
全部
|
||||
</wd-radio>
|
||||
<wd-radio :value="10">
|
||||
未审核
|
||||
</wd-radio>
|
||||
<wd-radio :value="20">
|
||||
已审核
|
||||
</wd-radio>
|
||||
<wd-radio :value="30">
|
||||
不合格
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">
|
||||
重置
|
||||
</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">
|
||||
搜索
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { getNavbarHeight } from '@/utils'
|
||||
|
||||
const emit = defineEmits<{
|
||||
search: [data: Record<string, any>]
|
||||
reset: []
|
||||
}>()
|
||||
|
||||
const visible = ref(false)
|
||||
const formData = reactive({
|
||||
no: undefined as string | undefined,
|
||||
status: -1,
|
||||
})
|
||||
|
||||
const statusMap: Record<number, string> = {
|
||||
10: '未审核',
|
||||
20: '已审核',
|
||||
30: '不合格',
|
||||
}
|
||||
|
||||
/** 搜索条件 placeholder 拼接 */
|
||||
const placeholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (formData.no) {
|
||||
conditions.push(`编号:${formData.no}`)
|
||||
}
|
||||
if (formData.status !== -1) {
|
||||
conditions.push(`状态:${statusMap[formData.status] || formData.status}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索采购入库单'
|
||||
})
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
visible.value = false
|
||||
const params: Record<string, any> = {}
|
||||
if (formData.no) {
|
||||
params.no = formData.no
|
||||
}
|
||||
if (formData.status !== -1) {
|
||||
params.status = formData.status
|
||||
}
|
||||
emit('search', params)
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
formData.no = undefined
|
||||
formData.status = -1
|
||||
visible.value = false
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
395
src/pages-erp/purchase-in/detail/index.vue
Normal file
395
src/pages-erp/purchase-in/detail/index.vue
Normal file
@@ -0,0 +1,395 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采购入库详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view v-if="formData">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="入库单编号" :value="formData.no" />
|
||||
<wd-cell title="审核状态">
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getStatusClass(formData.status, formData.isQualified)"
|
||||
>
|
||||
{{ getStatusText(formData.status, formData.isQualified) }}
|
||||
</view>
|
||||
</wd-cell>
|
||||
<wd-cell title="供应商" :value="formData.supplierName || '-'" />
|
||||
<wd-cell title="入库时间" :value="formatDateTime(formData.inTime)" />
|
||||
<wd-cell title="关联订单" :value="formData.orderNo || '-'" />
|
||||
<wd-cell title="创建人" :value="formData.creatorName || '-'" />
|
||||
<wd-cell title="创建时间" :value="formatDateTime(formData.createTime)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="合计数量" :value="String(formData.totalCount || 0)" />
|
||||
<wd-cell title="合计产品价格" :value="`¥${formData.totalProductPrice || 0}`" />
|
||||
<wd-cell title="合计税额" :value="`¥${formData.totalTaxPrice || 0}`" />
|
||||
<wd-cell title="优惠率" :value="`${formData.discountPercent || 0}%`" />
|
||||
<wd-cell title="优惠金额" :value="`¥${formData.discountPrice || 0}`" />
|
||||
<wd-cell title="其他费用" :value="`¥${formData.otherPrice || 0}`" />
|
||||
<wd-cell title="应付金额">
|
||||
<text class="text-[#e6a23c] font-semibold">¥{{ formData.totalPrice || 0 }}</text>
|
||||
</wd-cell>
|
||||
<wd-cell title="已付金额">
|
||||
<text class="text-[#52c41a] font-semibold">¥{{ formData.paymentPrice || 0 }}</text>
|
||||
</wd-cell>
|
||||
<wd-cell title="未付金额">
|
||||
<text
|
||||
class="font-semibold"
|
||||
:class="(formData.totalPrice || 0) - (formData.paymentPrice || 0) > 0 ? 'text-[#f5222d]' : 'text-[#999]'"
|
||||
>
|
||||
¥{{ (formData.totalPrice || 0) - (formData.paymentPrice || 0) }}
|
||||
</text>
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 不合格信息 -->
|
||||
<wd-cell-group v-if="formData.status !== 10 && !formData.isQualified" title="不合格信息" border>
|
||||
<wd-cell title="返回方式" :value="getReturnTypeLabel(formData.returnType)" />
|
||||
<wd-cell v-if="formData.returnRemark" title="返回备注" :value="formData.returnRemark" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 入库明细 -->
|
||||
<view class="mx-24rpx mt-24rpx">
|
||||
<view class="mb-16rpx text-32rpx text-[#333] font-semibold">
|
||||
入库明细({{ formData.items?.length || 0 }}项)
|
||||
</view>
|
||||
<view v-if="formData.items && formData.items.length > 0">
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="item.id || index"
|
||||
class="mb-16rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
>
|
||||
<!-- 产品头部 -->
|
||||
<view class="flex items-center justify-between bg-[#f8f8f8] px-24rpx py-16rpx">
|
||||
<view class="flex items-center">
|
||||
<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>
|
||||
<view class="p-24rpx">
|
||||
<!-- 产品规格 -->
|
||||
<view v-if="item.productSpec" class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<text class="mr-8rpx text-[#999]">规格:</text>
|
||||
<text>{{ item.productSpec }}</text>
|
||||
</view>
|
||||
<!-- 单价 / 数量 / 单位 -->
|
||||
<view class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">单价:</text>
|
||||
<text class="text-[#f5222d]">¥{{ item.productPrice || 0 }}</text>
|
||||
</view>
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">数量:</text>
|
||||
<text class="font-semibold">{{ item.count || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">单位:</text>
|
||||
<text>{{ item.productUnitName || '-' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 税率 / 税额 -->
|
||||
<view v-if="item.taxPercent" class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">税率:</text>
|
||||
<text>{{ item.taxPercent }}%</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">税额:</text>
|
||||
<text>¥{{ item.taxPrice || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 金额 / 库存 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">金额:</text>
|
||||
<text class="text-[#e6a23c]">¥{{ item.totalPrice || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">库存:</text>
|
||||
<text>{{ item.stockCount || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 备注 -->
|
||||
<view v-if="item.remark" class="text-24rpx text-[#999]">
|
||||
备注:{{ item.remark }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="py-60rpx text-center text-28rpx text-[#999]">
|
||||
暂无入库明细
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 备注 -->
|
||||
<wd-cell-group v-if="formData.remark" title="备注" border>
|
||||
<wd-cell :value="formData.remark" />
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<view class="yd-detail-footer-actions">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:update']) && formData?.status === 10"
|
||||
class="flex-1" type="warning" @click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:update-status']) && formData?.status === 10"
|
||||
class="flex-1" type="success" @click="handleAudit"
|
||||
>
|
||||
审核
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:update-status']) && (formData?.status === 20 || formData?.status === 30)"
|
||||
class="flex-1" type="warning" @click="handleReverseAudit"
|
||||
>
|
||||
反审核
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:delete']) && formData?.status === 10"
|
||||
class="flex-1" type="error" :loading="deleting" @click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 审核弹窗 -->
|
||||
<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>
|
||||
<view class="mb-24rpx">
|
||||
<view class="text-26rpx text-[#666] mb-12rpx">是否合格</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>
|
||||
<wd-radio-group v-model="auditForm.returnType" shape="button">
|
||||
<wd-radio
|
||||
v-for="opt in RETURN_TYPE_OPTIONS"
|
||||
:key="opt.value"
|
||||
:value="opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</view>
|
||||
<view v-if="!auditForm.isQualified" class="mb-24rpx">
|
||||
<view class="text-26rpx text-[#666] mb-12rpx">返回备注</view>
|
||||
<wd-textarea
|
||||
v-model="auditForm.returnRemark"
|
||||
placeholder="请输入返回方式备注"
|
||||
:maxlength="200"
|
||||
/>
|
||||
</view>
|
||||
<view class="flex gap-24rpx mt-32rpx">
|
||||
<wd-button class="flex-1" plain @click="auditVisible = false">
|
||||
取消
|
||||
</wd-button>
|
||||
<wd-button class="flex-1" type="primary" :loading="auditLoading" @click="submitAudit">
|
||||
确定
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PurchaseIn } from '@/api/erp/purchase-in'
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deletePurchaseIn, getPurchaseIn, RETURN_TYPE_OPTIONS, updatePurchaseInStatus } from '@/api/erp/purchase-in'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
import { formatDateTime } from '@/utils/date'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const formData = ref<PurchaseIn>()
|
||||
const deleting = ref(false)
|
||||
|
||||
// 审核相关
|
||||
const auditVisible = ref(false)
|
||||
const auditLoading = ref(false)
|
||||
const auditForm = reactive({
|
||||
isQualified: true,
|
||||
returnType: undefined as string | undefined,
|
||||
returnRemark: undefined as string | undefined,
|
||||
})
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number, isQualified?: boolean) {
|
||||
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]'
|
||||
return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
|
||||
/** 获取返回方式标签 */
|
||||
function getReturnTypeLabel(value?: string | null) {
|
||||
if (!value) return '-'
|
||||
const option = RETURN_TYPE_OPTIONS.find(opt => opt.value === value)
|
||||
return option ? option.label : value
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/purchase-in/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getPurchaseIn(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑操作 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-in/form/index?id=${props.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 打开审核弹窗 */
|
||||
function handleAudit() {
|
||||
auditForm.isQualified = true
|
||||
auditForm.returnType = undefined
|
||||
auditForm.returnRemark = undefined
|
||||
auditVisible.value = true
|
||||
}
|
||||
|
||||
/** 合格状态变化 */
|
||||
function handleQualifiedChange(val: boolean) {
|
||||
if (val) {
|
||||
auditForm.returnType = undefined
|
||||
auditForm.returnRemark = undefined
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交审核 */
|
||||
async function submitAudit() {
|
||||
if (!props.id) return
|
||||
if (!auditForm.isQualified && !auditForm.returnType) {
|
||||
toast.warning('请选择返回方式')
|
||||
return
|
||||
}
|
||||
auditLoading.value = true
|
||||
try {
|
||||
await updatePurchaseInStatus({
|
||||
id: props.id,
|
||||
isQualified: auditForm.isQualified,
|
||||
returnType: auditForm.returnType,
|
||||
returnRemark: auditForm.returnRemark,
|
||||
status: auditForm.isQualified ? 20 : 30,
|
||||
})
|
||||
toast.success('审核成功')
|
||||
auditVisible.value = false
|
||||
getDetail()
|
||||
} finally {
|
||||
auditLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 反审核操作 */
|
||||
function handleReverseAudit() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审核该入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await updatePurchaseInStatus({
|
||||
id: props.id,
|
||||
isQualified: false,
|
||||
status: 10,
|
||||
})
|
||||
toast.success('反审核成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除操作 */
|
||||
function handleDelete() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该采购入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
deleting.value = true
|
||||
try {
|
||||
await deletePurchaseIn([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
612
src/pages-erp/purchase-in/form/index.vue
Normal file
612
src/pages-erp/purchase-in/form/index.vue
Normal file
@@ -0,0 +1,612 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view>
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="入库单号" title-width="180rpx" center>
|
||||
<wd-input
|
||||
v-model="formData.no"
|
||||
placeholder="不填则自动生成"
|
||||
:disabled="!!props.id"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="入库时间" title-width="180rpx" prop="inTime" center>
|
||||
<wd-datetime-picker
|
||||
v-model="formData.inTime"
|
||||
type="date"
|
||||
label=""
|
||||
placeholder="请选择入库时间"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="关联订单" title-width="180rpx" center is-link @click="openOrderSelect">
|
||||
<text v-if="formData.orderNo" class="text-[#1890ff]">{{ formData.orderNo }}</text>
|
||||
<text v-else class="text-[#999]">点击选择采购订单</text>
|
||||
</wd-cell>
|
||||
<wd-cell title="供应商" title-width="180rpx" center>
|
||||
<text>{{ getSupplierName() || '-' }}</text>
|
||||
</wd-cell>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-cell-group title="费用信息" border>
|
||||
<wd-input
|
||||
v-model="formData.discountPercent"
|
||||
label="优惠率(%)"
|
||||
label-width="180rpx"
|
||||
type="number"
|
||||
placeholder="请输入优惠率"
|
||||
clearable
|
||||
/>
|
||||
<wd-cell title="付款优惠" title-width="180rpx" center>
|
||||
<text>¥{{ formData.discountPrice || 0 }}</text>
|
||||
</wd-cell>
|
||||
<wd-input
|
||||
v-model="formData.otherPrice"
|
||||
label="其他费用"
|
||||
label-width="180rpx"
|
||||
type="number"
|
||||
placeholder="请输入其他费用"
|
||||
clearable
|
||||
/>
|
||||
<wd-cell title="优惠后金额" title-width="180rpx" center>
|
||||
<text>¥{{ (formData.totalPrice || 0) - (formData.otherPrice || 0) }}</text>
|
||||
</wd-cell>
|
||||
<wd-cell title="结算账户" title-width="180rpx" prop="accountId" center>
|
||||
<wd-picker
|
||||
v-model="formData.accountId"
|
||||
:columns="accountColumns"
|
||||
label=""
|
||||
placeholder="请选择结算账户"
|
||||
@confirm="onAccountConfirm"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="应付金额" title-width="180rpx" center>
|
||||
<text class="text-[#e6a23c] font-semibold">¥{{ formData.totalPrice || 0 }}</text>
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 入库明细 -->
|
||||
<view class="mx-24rpx mt-24rpx pb-180rpx">
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-32rpx text-[#333] font-semibold">
|
||||
入库明细({{ formData.items?.length || 0 }}项)
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mb-16rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
>
|
||||
<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>
|
||||
<view class="p-24rpx">
|
||||
<!-- 仓库选择 -->
|
||||
<view class="mb-16rpx">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">仓库</text>
|
||||
<wd-picker
|
||||
v-model="item.warehouseId"
|
||||
:columns="warehouseColumns"
|
||||
placeholder="请选择仓库"
|
||||
@confirm="(e: any) => onWarehouseConfirm(e, index)"
|
||||
/>
|
||||
</view>
|
||||
<!-- 自动填充的产品信息(只读) -->
|
||||
<view v-if="item.productId" class="mb-16rpx rounded-8rpx bg-[#f9f9f9] p-16rpx">
|
||||
<view class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">产品名称</text>
|
||||
<text class="text-[#333]">{{ item.productName || '-' }}</text>
|
||||
</view>
|
||||
<view v-if="item.productSpec" class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">规格</text>
|
||||
<text class="text-[#333]">{{ item.productSpec }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">单位</text>
|
||||
<text class="text-[#333]">{{ item.productUnitName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">条码</text>
|
||||
<text class="text-[#333]">{{ item.productBarCode || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">库存</text>
|
||||
<text class="text-[#333]">{{ item.stockCount || 0 }}</text>
|
||||
</view>
|
||||
<view v-if="item.totalCount != null" class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">原数量</text>
|
||||
<text class="text-[#333]">{{ item.totalCount }}</text>
|
||||
</view>
|
||||
<view v-if="item.inCount != null" class="flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">已入库</text>
|
||||
<text class="text-[#333]">{{ item.inCount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mb-16rpx flex gap-16rpx">
|
||||
<view class="flex-1">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">数量</text>
|
||||
<wd-input
|
||||
v-model="item.count"
|
||||
type="number"
|
||||
placeholder="数量"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="flex-1">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">单价(元)</text>
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
type="number"
|
||||
placeholder="单价"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mb-16rpx flex gap-16rpx">
|
||||
<view class="flex-1">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">税率(%)</text>
|
||||
<wd-input
|
||||
v-model="item.taxPercent"
|
||||
type="number"
|
||||
placeholder="税率"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="flex-1">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">金额</text>
|
||||
<text class="block pt-16rpx text-28rpx text-[#333]">{{ calcTotalPrice(item) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">备注</text>
|
||||
<wd-input
|
||||
v-model="item.remark"
|
||||
placeholder="请输入备注"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="!formData.items?.length" class="py-60rpx text-center text-28rpx text-[#999]">
|
||||
暂无产品,请先选择关联订单
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 采购订单选择弹窗 -->
|
||||
<wd-popup v-model="orderSelectVisible" position="right" custom-style="width: 100%; height: 100%;">
|
||||
<view class="yd-page-container">
|
||||
<wd-navbar
|
||||
title="选择采购订单"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="orderSelectVisible = false"
|
||||
/>
|
||||
<wd-search
|
||||
v-model="orderQueryParams.no"
|
||||
placeholder="搜索订单单号"
|
||||
@search="getOrderList"
|
||||
@clear="getOrderList"
|
||||
/>
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in orderList"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
:class="{ 'border-2 border-[#1890ff]': selectedOrderId === item.id }"
|
||||
@click="handleSelectOrder(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<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]">
|
||||
<text class="text-[#999]">供应商</text>
|
||||
<text>{{ item.supplierName || '-' }}</text>
|
||||
</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>
|
||||
</view>
|
||||
<view class="flex items-center justify-around mt-12rpx pt-12rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<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>
|
||||
<view class="text-center">
|
||||
<view class="text-28rpx text-[#e6a23c] font-semibold">¥{{ item.totalPrice || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999]">含税金额</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="orderList.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无可入库订单" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="orderList.length > 0"
|
||||
:state="orderLoadMoreState"
|
||||
@reload="loadMoreOrders"
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button type="primary" block :disabled="!selectedOrderId" @click="confirmSelectOrder">
|
||||
确认选择
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { PurchaseIn, PurchaseInItem } from '@/api/erp/purchase-in'
|
||||
import type { PurchaseOrder } from '@/api/erp/purchase-order'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createPurchaseIn, getPurchaseIn, updatePurchaseIn } from '@/api/erp/purchase-in'
|
||||
import { getPurchaseOrder, getPurchaseOrderPage } from '@/api/erp/purchase-order'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
/** 账户简单信息 */
|
||||
interface AccountSimple {
|
||||
id: number
|
||||
name: string
|
||||
defaultStatus?: boolean
|
||||
}
|
||||
|
||||
/** 仓库简单信息 */
|
||||
interface WarehouseSimple {
|
||||
id: number
|
||||
name: string
|
||||
defaultStatus?: boolean
|
||||
}
|
||||
|
||||
/** 供应商简单信息 */
|
||||
interface SupplierSimple {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const toast = useToast()
|
||||
const getTitle = computed(() => props.id ? '编辑采购入库' : '新增采购入库')
|
||||
const formLoading = ref(false)
|
||||
const formData = ref<PurchaseIn>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
supplierId: undefined,
|
||||
accountId: undefined,
|
||||
inTime: undefined,
|
||||
orderId: undefined,
|
||||
orderNo: undefined,
|
||||
discountPercent: 0,
|
||||
discountPrice: 0,
|
||||
otherPrice: 0,
|
||||
totalPrice: 0,
|
||||
remark: '',
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
inTime: [{ required: true, message: '入库时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
const supplierList = ref<SupplierSimple[]>([])
|
||||
const accountList = ref<AccountSimple[]>([])
|
||||
const warehouseList = ref<WarehouseSimple[]>([])
|
||||
const defaultWarehouse = ref<WarehouseSimple>()
|
||||
|
||||
// 采购订单选择相关
|
||||
const orderSelectVisible = ref(false)
|
||||
const orderList = ref<PurchaseOrder[]>([])
|
||||
const orderLoadMoreState = ref<LoadMoreState>('loading')
|
||||
const orderQueryParams = ref({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
no: undefined as string | undefined,
|
||||
inEnable: true,
|
||||
})
|
||||
const orderTotal = ref(0)
|
||||
const selectedOrderId = ref<number>()
|
||||
|
||||
/** 账户下拉列 */
|
||||
const accountColumns = computed(() => [
|
||||
accountList.value.map(a => ({ value: a.id, label: a.name })),
|
||||
])
|
||||
|
||||
/** 仓库下拉列 */
|
||||
const warehouseColumns = computed(() => [
|
||||
warehouseList.value.map(w => ({ value: w.id, label: w.name })),
|
||||
])
|
||||
|
||||
/** 获取供应商名称 */
|
||||
function getSupplierName() {
|
||||
if (!formData.value.supplierId) return ''
|
||||
const supplier = supplierList.value.find(s => s.id === formData.value.supplierId)
|
||||
return supplier?.name || formData.value.supplierName || ''
|
||||
}
|
||||
|
||||
/** 账户选择回调 */
|
||||
function onAccountConfirm({ value }: any) {
|
||||
formData.value.accountId = value?.[0]
|
||||
}
|
||||
|
||||
/** 仓库选择回调 */
|
||||
function onWarehouseConfirm({ value }: any, index: number) {
|
||||
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])
|
||||
if (warehouse) {
|
||||
formData.value.items[index].warehouseName = warehouse.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算行项金额 */
|
||||
function calcTotalPrice(item: PurchaseInItem) {
|
||||
if (item.productPrice && item.count) {
|
||||
const productTotal = Number(item.productPrice) * Number(item.count)
|
||||
const taxPrice = item.taxPercent ? productTotal * Number(item.taxPercent) / 100 : 0
|
||||
return `¥${(productTotal + taxPrice).toFixed(2)}`
|
||||
}
|
||||
return '-'
|
||||
}
|
||||
|
||||
/** 监听表单数据变化,计算总价 */
|
||||
watch(
|
||||
() => formData.value,
|
||||
(val) => {
|
||||
if (!val || !val.items) return
|
||||
// 计算每个明细的金额
|
||||
val.items.forEach((item) => {
|
||||
if (item.productPrice && item.count) {
|
||||
item.totalProductPrice = Number(item.productPrice) * Number(item.count)
|
||||
item.taxPrice = item.taxPercent ? item.totalProductPrice * Number(item.taxPercent) / 100 : 0
|
||||
item.totalPrice = item.totalProductPrice + (item.taxPrice || 0)
|
||||
}
|
||||
})
|
||||
// 计算总价
|
||||
const totalPrice = val.items.reduce((prev, curr) => prev + (curr.totalPrice || 0), 0)
|
||||
const discountPrice = val.discountPercent ? totalPrice * Number(val.discountPercent) / 100 : 0
|
||||
formData.value.discountPrice = Math.round(discountPrice * 100) / 100
|
||||
formData.value.totalPrice = Math.round((totalPrice - discountPrice + Number(val.otherPrice || 0)) * 100) / 100
|
||||
},
|
||||
{ deep: true },
|
||||
)
|
||||
|
||||
/** 加载下拉列表数据 */
|
||||
async function loadDropdownData() {
|
||||
try {
|
||||
const { http } = await import('@/http/http')
|
||||
const [suppliers, accounts, warehouses] = await Promise.all([
|
||||
http.get<SupplierSimple[]>('/erp/supplier/simple-list'),
|
||||
http.get<AccountSimple[]>('/erp/account/simple-list'),
|
||||
http.get<WarehouseSimple[]>('/erp/warehouse/simple-list'),
|
||||
])
|
||||
supplierList.value = suppliers || []
|
||||
accountList.value = accounts || []
|
||||
warehouseList.value = warehouses || []
|
||||
// 设置默认账户
|
||||
const defaultAccount = accountList.value.find(a => a.defaultStatus)
|
||||
if (defaultAccount && !formData.value.accountId) {
|
||||
formData.value.accountId = defaultAccount.id
|
||||
}
|
||||
// 设置默认仓库
|
||||
defaultWarehouse.value = warehouseList.value.find(w => w.defaultStatus)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/purchase-in/index')
|
||||
}
|
||||
|
||||
/** 删除入库明细行 */
|
||||
function handleRemoveItem(index: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `确定要删除第 ${index + 1} 项产品吗?`,
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 打开订单选择弹窗 */
|
||||
function openOrderSelect() {
|
||||
orderSelectVisible.value = true
|
||||
orderQueryParams.value.pageNo = 1
|
||||
orderList.value = []
|
||||
selectedOrderId.value = formData.value.orderId
|
||||
getOrderList()
|
||||
}
|
||||
|
||||
/** 获取可入库订单列表 */
|
||||
async function getOrderList() {
|
||||
orderLoadMoreState.value = 'loading'
|
||||
try {
|
||||
const data = await getPurchaseOrderPage(orderQueryParams.value)
|
||||
if (orderQueryParams.value.pageNo === 1) {
|
||||
orderList.value = data.list
|
||||
} else {
|
||||
orderList.value = [...orderList.value, ...data.list]
|
||||
}
|
||||
orderTotal.value = data.total
|
||||
orderLoadMoreState.value = orderList.value.length >= orderTotal.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
orderLoadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 加载更多订单 */
|
||||
function loadMoreOrders() {
|
||||
if (orderLoadMoreState.value === 'finished') return
|
||||
orderQueryParams.value.pageNo++
|
||||
getOrderList()
|
||||
}
|
||||
|
||||
/** 选择订单 */
|
||||
function handleSelectOrder(item: PurchaseOrder) {
|
||||
selectedOrderId.value = item.id
|
||||
}
|
||||
|
||||
/** 确认选择订单 */
|
||||
async function confirmSelectOrder() {
|
||||
if (!selectedOrderId.value) return
|
||||
try {
|
||||
toast.loading('加载订单详情...')
|
||||
const orderDetail = await getPurchaseOrder(selectedOrderId.value)
|
||||
// 设置订单信息
|
||||
formData.value.orderId = orderDetail.id
|
||||
formData.value.orderNo = orderDetail.no
|
||||
formData.value.supplierId = orderDetail.supplierId
|
||||
formData.value.supplierName = orderDetail.supplierName
|
||||
formData.value.accountId = orderDetail.accountId
|
||||
formData.value.discountPercent = orderDetail.discountPercent
|
||||
formData.value.remark = orderDetail.remark
|
||||
// 设置入库明细
|
||||
if (orderDetail.items) {
|
||||
formData.value.items = orderDetail.items
|
||||
.filter(item => (item.count || 0) - (item.inCount || 0) > 0)
|
||||
.map(item => ({
|
||||
productId: item.productId,
|
||||
productName: item.productName,
|
||||
productUnitId: item.productUnitId,
|
||||
productUnitName: item.productUnitName,
|
||||
productPrice: item.productPrice,
|
||||
productSpec: item.productSpec,
|
||||
productBarCode: item.productBarCode,
|
||||
count: (item.count || 0) - (item.inCount || 0),
|
||||
totalCount: item.count,
|
||||
inCount: item.inCount,
|
||||
taxPercent: item.taxPercent,
|
||||
warehouseId: defaultWarehouse.value?.id,
|
||||
warehouseName: defaultWarehouse.value?.name,
|
||||
stockCount: item.stockCount,
|
||||
orderItemId: item.id,
|
||||
remark: item.remark,
|
||||
}))
|
||||
}
|
||||
orderSelectVisible.value = false
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getPurchaseIn(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) {
|
||||
return
|
||||
}
|
||||
// 校验入库明细
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.warning('请至少添加一项入库产品')
|
||||
return
|
||||
}
|
||||
for (let i = 0; i < formData.value.items.length; i++) {
|
||||
const item = formData.value.items[i]
|
||||
if (!item.warehouseId) {
|
||||
toast.warning(`第 ${i + 1} 项产品请选择仓库`)
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.warning(`第 ${i + 1} 项产品数量不能为空`)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
if (props.id) {
|
||||
await updatePurchaseIn(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createPurchaseIn(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
await loadDropdownData()
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
447
src/pages-erp/purchase-in/index.vue
Normal file
447
src/pages-erp/purchase-in/index.vue
Normal file
@@ -0,0 +1,447 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采购入库"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<SearchForm @search="handleQuery" @reset="handleReset" />
|
||||
|
||||
<!-- 状态快速筛选 -->
|
||||
<view class="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
: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]"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 采购入库列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
@click="handleCardClick(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:单号 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.no }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getStatusClass(item.status, item.isQualified)"
|
||||
>
|
||||
{{ getStatusText(item.status, item.isQualified) }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 供应商 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">供应商</text>
|
||||
<text>{{ item.supplierName || '-' }}</text>
|
||||
</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>
|
||||
</view>
|
||||
<!-- 入库时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">入库时间</text>
|
||||
<text>{{ formatDate(item.inTime) }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<view class="text-center">
|
||||
<view
|
||||
class="text-30rpx font-semibold"
|
||||
:class="(item.totalPrice || 0) - (item.paymentPrice || 0) > 0 ? 'text-[#f5222d]' : 'text-[#999]'"
|
||||
>
|
||||
¥{{ (item.totalPrice || 0) - (item.paymentPrice || 0) }}
|
||||
</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">未付</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:query'])"
|
||||
size="small" plain @click="handleDetail(item)"
|
||||
>
|
||||
详情
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:update']) && item.status === 10"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
修改
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleAudit(item)"
|
||||
>
|
||||
审核
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:update-status']) && (item.status === 20 || item.status === 30)"
|
||||
size="small" type="warning" plain @click="handleReverseAudit(item.id!)"
|
||||
>
|
||||
反审核
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:delete']) && item.status === 10"
|
||||
size="small" type="error" plain @click="handleDelete(item.id!)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无采购入库数据" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 新增按钮 -->
|
||||
<wd-fab
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 审核弹窗 -->
|
||||
<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>
|
||||
<view class="mb-24rpx">
|
||||
<view class="text-26rpx text-[#666] mb-12rpx">是否合格</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>
|
||||
<wd-radio-group v-model="auditForm.returnType" shape="button">
|
||||
<wd-radio
|
||||
v-for="opt in RETURN_TYPE_OPTIONS"
|
||||
:key="opt.value"
|
||||
:value="opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</view>
|
||||
<view v-if="!auditForm.isQualified" class="mb-24rpx">
|
||||
<view class="text-26rpx text-[#666] mb-12rpx">返回备注</view>
|
||||
<wd-textarea
|
||||
v-model="auditForm.returnRemark"
|
||||
placeholder="请输入返回方式备注"
|
||||
:maxlength="200"
|
||||
/>
|
||||
</view>
|
||||
<view class="flex gap-24rpx mt-32rpx">
|
||||
<wd-button class="flex-1" plain @click="auditVisible = false">
|
||||
取消
|
||||
</wd-button>
|
||||
<wd-button class="flex-1" type="primary" :loading="auditLoading" @click="submitAudit">
|
||||
确定
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PurchaseIn } from '@/api/erp/purchase-in'
|
||||
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 { deletePurchaseIn, getPurchaseInPage, RETURN_TYPE_OPTIONS, updatePurchaseInStatus } from '@/api/erp/purchase-in'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
import SearchForm from './components/search-form.vue'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<PurchaseIn[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const activeStatus = ref<number | undefined>(undefined)
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
const statusTabs = [
|
||||
{ label: '全部', value: undefined },
|
||||
{ label: '未审核', value: 10 },
|
||||
{ label: '已审核', value: 20 },
|
||||
{ label: '不合格', value: 30 },
|
||||
]
|
||||
|
||||
// 审核相关
|
||||
const auditVisible = ref(false)
|
||||
const auditLoading = ref(false)
|
||||
const auditForm = reactive({
|
||||
id: undefined as number | undefined,
|
||||
isQualified: true,
|
||||
returnType: undefined as string | undefined,
|
||||
returnRemark: undefined as string | undefined,
|
||||
})
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(date?: string) {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleDateString('zh-CN')
|
||||
}
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number, isQualified?: boolean) {
|
||||
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]'
|
||||
return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询采购入库列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
const data = await getPurchaseInPage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 状态快速筛选 */
|
||||
function handleQuickFilter(status?: number) {
|
||||
activeStatus.value = status
|
||||
queryParams.value.status = status
|
||||
queryParams.value.pageNo = 1
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery(data?: Record<string, any>) {
|
||||
queryParams.value = {
|
||||
...data,
|
||||
status: activeStatus.value,
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function handleReset() {
|
||||
activeStatus.value = undefined
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') {
|
||||
return
|
||||
}
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 卡片点击 — 已审核打开详情,未审核打开编辑 */
|
||||
function handleCardClick(item: PurchaseIn) {
|
||||
if (item.status === 20 || item.status === 30) {
|
||||
handleDetail(item)
|
||||
} else if (item.status === 10) {
|
||||
handleEdit(item)
|
||||
}
|
||||
}
|
||||
|
||||
/** 新增采购入库 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({
|
||||
url: '/pages-erp/purchase-in/form/index',
|
||||
})
|
||||
}
|
||||
|
||||
/** 查看详情 */
|
||||
function handleDetail(item: PurchaseIn) {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-in/detail/index?id=${item.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: PurchaseIn) {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-in/form/index?id=${item.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 打开审核弹窗 */
|
||||
function handleAudit(item: PurchaseIn) {
|
||||
auditForm.id = item.id
|
||||
auditForm.isQualified = true
|
||||
auditForm.returnType = undefined
|
||||
auditForm.returnRemark = undefined
|
||||
auditVisible.value = true
|
||||
}
|
||||
|
||||
/** 合格状态变化 */
|
||||
function handleQualifiedChange(val: boolean) {
|
||||
if (val) {
|
||||
auditForm.returnType = undefined
|
||||
auditForm.returnRemark = undefined
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交审核 */
|
||||
async function submitAudit() {
|
||||
if (!auditForm.id) return
|
||||
if (!auditForm.isQualified && !auditForm.returnType) {
|
||||
toast.warning('请选择返回方式')
|
||||
return
|
||||
}
|
||||
auditLoading.value = true
|
||||
try {
|
||||
await updatePurchaseInStatus({
|
||||
id: auditForm.id,
|
||||
isQualified: auditForm.isQualified,
|
||||
returnType: auditForm.returnType,
|
||||
returnRemark: auditForm.returnRemark,
|
||||
status: auditForm.isQualified ? 20 : 30,
|
||||
})
|
||||
toast.success('审核成功')
|
||||
auditVisible.value = false
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} finally {
|
||||
auditLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 反审核 */
|
||||
function handleReverseAudit(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定反审核该入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePurchaseInStatus({
|
||||
id,
|
||||
isQualified: false,
|
||||
status: 10,
|
||||
})
|
||||
toast.success('反审核成功')
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该采购入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deletePurchaseIn([id])
|
||||
toast.success('删除成功')
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
104
src/pages-erp/purchase-order/components/search-form.vue
Normal file
104
src/pages-erp/purchase-order/components/search-form.vue
Normal file
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<!-- 搜索框入口 -->
|
||||
<view @click="visible = true">
|
||||
<wd-search :placeholder="placeholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="visible" position="top" @close="visible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">
|
||||
采购单编号
|
||||
</view>
|
||||
<wd-input
|
||||
v-model="formData.no"
|
||||
placeholder="请输入采购单编号"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">
|
||||
采购状态
|
||||
</view>
|
||||
<wd-radio-group v-model="formData.status" shape="button">
|
||||
<wd-radio :value="-1">
|
||||
全部
|
||||
</wd-radio>
|
||||
<wd-radio :value="10">
|
||||
未审批
|
||||
</wd-radio>
|
||||
<wd-radio :value="20">
|
||||
已审批
|
||||
</wd-radio>
|
||||
<wd-radio :value="30">
|
||||
已驳回
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">
|
||||
重置
|
||||
</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">
|
||||
搜索
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { getNavbarHeight } from '@/utils'
|
||||
|
||||
const emit = defineEmits<{
|
||||
search: [data: Record<string, any>]
|
||||
reset: []
|
||||
}>()
|
||||
|
||||
const visible = ref(false)
|
||||
const formData = reactive({
|
||||
no: undefined as string | undefined,
|
||||
status: -1,
|
||||
})
|
||||
|
||||
const statusMap: Record<number, string> = {
|
||||
10: '未审批',
|
||||
20: '已审批',
|
||||
30: '已驳回',
|
||||
}
|
||||
|
||||
/** 搜索条件 placeholder 拼接 */
|
||||
const placeholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (formData.no) {
|
||||
conditions.push(`编号:${formData.no}`)
|
||||
}
|
||||
if (formData.status !== -1) {
|
||||
conditions.push(`状态:${statusMap[formData.status] || formData.status}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索采购订单'
|
||||
})
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
visible.value = false
|
||||
const params: Record<string, any> = {}
|
||||
if (formData.no) {
|
||||
params.no = formData.no
|
||||
}
|
||||
if (formData.status !== -1) {
|
||||
params.status = formData.status
|
||||
}
|
||||
emit('search', params)
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
formData.no = undefined
|
||||
formData.status = -1
|
||||
visible.value = false
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
297
src/pages-erp/purchase-order/detail/index.vue
Normal file
297
src/pages-erp/purchase-order/detail/index.vue
Normal file
@@ -0,0 +1,297 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采购订单详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view v-if="formData">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="采购单编号" :value="formData.no" />
|
||||
<wd-cell title="采购状态">
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getStatusClass(formData.status)"
|
||||
>
|
||||
{{ getStatusText(formData.status) }}
|
||||
</view>
|
||||
</wd-cell>
|
||||
<wd-cell title="供应商" :value="formData.supplierName || '-'" />
|
||||
<wd-cell title="下单时间" :value="formatDateTime(formData.orderTime)" />
|
||||
<wd-cell title="创建人" :value="formData.creatorName || '-'" />
|
||||
<wd-cell title="审核人" :value="formData.auditorName || '-'" />
|
||||
<wd-cell title="创建时间" :value="formatDateTime(formData.createTime)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 合同信息 -->
|
||||
<wd-cell-group title="合同信息" border>
|
||||
<wd-cell title="发票类别" :value="formData.invoiceTypeName || '-'" />
|
||||
<wd-cell title="运费承担方" :value="formData.freightPayerName || '-'" />
|
||||
<wd-cell title="结算方式" :value="formData.settlementMethodName || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="合计数量" :value="String(formData.totalCount || 0)" />
|
||||
<wd-cell title="合计产品价格" :value="`¥${formData.totalProductPrice || 0}`" />
|
||||
<wd-cell title="合计税额" :value="`¥${formData.totalTaxPrice || 0}`" />
|
||||
<wd-cell title="优惠率" :value="`${formData.discountPercent || 0}%`" />
|
||||
<wd-cell title="优惠金额" :value="`¥${formData.discountPrice || 0}`" />
|
||||
<wd-cell title="定金金额" :value="`¥${formData.depositPrice || 0}`" />
|
||||
<wd-cell title="最终合计价格">
|
||||
<text class="text-[#f5222d] font-semibold">¥{{ formData.totalPrice || 0 }}</text>
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 入库/退货信息 -->
|
||||
<wd-cell-group title="入库/退货" border>
|
||||
<wd-cell title="入库数量" :value="String(formData.inCount || 0)" />
|
||||
<wd-cell title="退货数量" :value="String(formData.returnCount || 0)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 请购单信息 -->
|
||||
<wd-cell-group v-if="formData.purchaseRequisitionNo" title="关联请购单" border>
|
||||
<wd-cell title="请购单编号" :value="formData.purchaseRequisitionNo" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 订单明细 -->
|
||||
<view class="mx-24rpx mt-24rpx">
|
||||
<view class="mb-16rpx text-32rpx text-[#333] font-semibold">
|
||||
订单明细({{ formData.items?.length || 0 }}项)
|
||||
</view>
|
||||
<view v-if="formData.items && formData.items.length > 0">
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="item.id || index"
|
||||
class="mb-16rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
>
|
||||
<!-- 产品头部 -->
|
||||
<view class="flex items-center justify-between bg-[#f8f8f8] px-24rpx py-16rpx">
|
||||
<view class="flex items-center">
|
||||
<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.supplierName" class="text-24rpx text-[#1890ff]">{{ item.supplierName }}</text>
|
||||
</view>
|
||||
<view class="p-24rpx">
|
||||
<!-- 产品规格 -->
|
||||
<view v-if="item.productSpec" class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<text class="mr-8rpx text-[#999]">规格:</text>
|
||||
<text>{{ item.productSpec }}</text>
|
||||
</view>
|
||||
<!-- 单价 / 数量 / 单位 -->
|
||||
<view class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">单价:</text>
|
||||
<text class="text-[#f5222d]">¥{{ item.productPrice || 0 }}</text>
|
||||
</view>
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">数量:</text>
|
||||
<text class="font-semibold">{{ item.count || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">单位:</text>
|
||||
<text>{{ item.productUnitName || '-' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 税率 / 税额 -->
|
||||
<view v-if="item.taxPercent" class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">税率:</text>
|
||||
<text>{{ item.taxPercent }}%</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">税额:</text>
|
||||
<text>¥{{ item.taxPrice || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 入库 / 退货 / 库存 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">入库:</text>
|
||||
<text>{{ item.inCount || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">退货:</text>
|
||||
<text>{{ item.returnCount || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">库存:</text>
|
||||
<text>{{ item.stockCount || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 备注 -->
|
||||
<view v-if="item.remark" class="text-24rpx text-[#999]">
|
||||
备注:{{ item.remark }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="py-60rpx text-center text-28rpx text-[#999]">
|
||||
暂无订单明细
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 备注 -->
|
||||
<wd-cell-group v-if="formData.remark" title="备注" border>
|
||||
<wd-cell :value="formData.remark" />
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<view class="yd-detail-footer-actions">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:update']) && formData?.status === 10"
|
||||
class="flex-1" type="warning" @click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:update-status']) && formData?.status === 10"
|
||||
class="flex-1" type="success" @click="handleApprove"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:delete']) && formData?.status !== 20"
|
||||
class="flex-1" type="error" :loading="deleting" @click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PurchaseOrder } from '@/api/erp/purchase-order'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deletePurchaseOrder, getPurchaseOrder, updatePurchaseOrderStatus } from '@/api/erp/purchase-order'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
import { formatDateTime } from '@/utils/date'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const formData = ref<PurchaseOrder>()
|
||||
const deleting = ref(false)
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number) {
|
||||
switch (status) {
|
||||
case 10: return '未审批'
|
||||
case 20: return '已审批'
|
||||
case 30: return '已驳回'
|
||||
default: return '未知'
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number) {
|
||||
switch (status) {
|
||||
case 10: return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
case 20: return 'bg-[#f6ffed] text-[#52c41a]'
|
||||
case 30: return 'bg-[#fff1f0] text-[#f5222d]'
|
||||
default: return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/purchase-order/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getPurchaseOrder(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑操作 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-order/form/index?id=${props.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 审批操作 */
|
||||
function handleApprove() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批通过该采购订单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await updatePurchaseOrderStatus(props.id, 20)
|
||||
toast.success('审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除操作 */
|
||||
function handleDelete() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该采购订单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
deleting.value = true
|
||||
try {
|
||||
await deletePurchaseOrder([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
529
src/pages-erp/purchase-order/form/index.vue
Normal file
529
src/pages-erp/purchase-order/form/index.vue
Normal file
@@ -0,0 +1,529 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view>
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="关联请购单" title-width="180rpx" is-link center @click="openRequisitionPicker">
|
||||
<text v-if="formData.purchaseRequisitionNo" class="text-[#1890ff]">{{ formData.purchaseRequisitionNo }}</text>
|
||||
<text v-else class="text-[#999]">请选择(可选)</text>
|
||||
</wd-cell>
|
||||
<wd-cell title="供应商" title-width="180rpx" prop="supplierId" center>
|
||||
<wd-picker
|
||||
v-model="formData.supplierId"
|
||||
:columns="supplierColumns"
|
||||
label=""
|
||||
placeholder="请选择供应商"
|
||||
@confirm="onSupplierConfirm"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="采购时间" title-width="180rpx" prop="orderTime" center>
|
||||
<wd-datetime-picker
|
||||
v-model="formData.orderTime"
|
||||
type="datetime"
|
||||
label=""
|
||||
placeholder="请选择采购时间"
|
||||
/>
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-cell-group title="合同信息" border>
|
||||
<wd-cell title="发票类别" title-width="180rpx" center>
|
||||
<wd-radio-group v-model="formData.invoiceType" shape="button">
|
||||
<wd-radio :value="1">
|
||||
增值税普通发票
|
||||
</wd-radio>
|
||||
<wd-radio :value="2">
|
||||
增值税专用发票
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</wd-cell>
|
||||
<wd-cell title="运费承担方" title-width="180rpx" center>
|
||||
<wd-radio-group v-model="formData.freightPayer" shape="button">
|
||||
<wd-radio :value="1">
|
||||
卖方承担
|
||||
</wd-radio>
|
||||
<wd-radio :value="2">
|
||||
买方承担
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</wd-cell>
|
||||
<wd-cell title="结算方式" title-width="180rpx" center>
|
||||
<wd-radio-group v-model="formData.settlementMethod" shape="button">
|
||||
<wd-radio :value="1">
|
||||
款到发货
|
||||
</wd-radio>
|
||||
<wd-radio :value="2">
|
||||
货到票到付款
|
||||
</wd-radio>
|
||||
<wd-radio :value="3">
|
||||
预付部分货到付清
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-cell-group title="其他信息" border>
|
||||
<wd-input
|
||||
v-model="formData.discountPercent"
|
||||
label="优惠率(%)"
|
||||
label-width="180rpx"
|
||||
type="number"
|
||||
placeholder="请输入优惠率"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.depositPrice"
|
||||
label="定金金额"
|
||||
label-width="180rpx"
|
||||
type="number"
|
||||
placeholder="请输入定金金额"
|
||||
clearable
|
||||
/>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 订单明细 -->
|
||||
<view class="mx-24rpx mt-24rpx pb-180rpx">
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-32rpx text-[#333] font-semibold">
|
||||
订单明细({{ formData.items?.length || 0 }}项)
|
||||
</view>
|
||||
<wd-button size="small" type="primary" @click="handleAddItem">
|
||||
+ 添加产品
|
||||
</wd-button>
|
||||
</view>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mb-16rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
>
|
||||
<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 size="small" type="error" plain @click="handleRemoveItem(index)">
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
<view class="p-24rpx">
|
||||
<view class="mb-16rpx">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">选择产品</text>
|
||||
<wd-picker
|
||||
v-model="item.productId"
|
||||
:columns="productColumns"
|
||||
placeholder="请选择产品"
|
||||
@confirm="(e: any) => onProductConfirm(e, index)"
|
||||
/>
|
||||
</view>
|
||||
<!-- 自动填充的产品信息(只读) -->
|
||||
<view v-if="item.productId" class="mb-16rpx rounded-8rpx bg-[#f9f9f9] p-16rpx">
|
||||
<view class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">规格</text>
|
||||
<text class="text-[#333]">{{ item.productSpec || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">单位</text>
|
||||
<text class="text-[#333]">{{ item.productUnitName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">条码</text>
|
||||
<text class="text-[#333]">{{ item.productBarCode || '-' }}</text>
|
||||
</view>
|
||||
<view class="flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">供应商</text>
|
||||
<text class="text-[#333]">{{ item.supplierName || '-' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mb-16rpx flex gap-16rpx">
|
||||
<view class="flex-1">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">数量</text>
|
||||
<wd-input
|
||||
v-model="item.count"
|
||||
type="number"
|
||||
placeholder="数量"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="flex-1">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">单价(元)</text>
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
type="number"
|
||||
placeholder="单价"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mb-16rpx flex gap-16rpx">
|
||||
<view class="flex-1">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">税率(%)</text>
|
||||
<wd-input
|
||||
v-model="item.taxPercent"
|
||||
type="number"
|
||||
placeholder="税率"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="flex-1">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">金额</text>
|
||||
<text class="block pt-16rpx text-28rpx text-[#333]">{{ calcTotalPrice(item) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">备注</text>
|
||||
<wd-input
|
||||
v-model="item.remark"
|
||||
placeholder="请输入备注"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="!formData.items?.length" class="py-60rpx text-center text-28rpx text-[#999]">
|
||||
暂无产品,请点击“添加产品”按钮
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 请购单选择弹窗 -->
|
||||
<wd-popup v-model="requisitionPickerVisible" position="bottom" :safe-area-inset-bottom="true">
|
||||
<view class="bg-white">
|
||||
<view class="flex items-center justify-between border-b border-[#eee] px-24rpx py-24rpx">
|
||||
<text class="text-32rpx font-semibold">选择请购单</text>
|
||||
<wd-icon name="close" size="40rpx" @click="requisitionPickerVisible = false" />
|
||||
</view>
|
||||
<view class="max-h-[60vh] overflow-y-auto">
|
||||
<view v-if="requisitionLoading" class="py-60rpx text-center text-[#999]">
|
||||
加载中...
|
||||
</view>
|
||||
<view v-else-if="requisitionList.length === 0" class="py-60rpx text-center text-[#999]">
|
||||
暂无已审核的请购单
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="req in requisitionList"
|
||||
:key="req.id"
|
||||
class="border-b border-[#f5f5f5] px-24rpx py-20rpx"
|
||||
@click="onRequisitionSelect(req)"
|
||||
>
|
||||
<view class="mb-8rpx flex items-center justify-between">
|
||||
<text class="text-28rpx text-[#333] font-semibold">{{ req.no }}</text>
|
||||
<text class="text-24rpx text-[#1890ff]">¥{{ req.totalPrice || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-24rpx text-[#999]">
|
||||
<text>请购人:{{ req.requesterNickname || '-' }}</text>
|
||||
<text>{{ formatDate(req.requestTime) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { PurchaseOrder, PurchaseOrderItem } from '@/api/erp/purchase-order'
|
||||
import type { ProductSimple } from '@/api/erp/product'
|
||||
import type { SupplierSimple } from '@/api/erp/supplier'
|
||||
import type { PurchaseRequisition } from '@/api/erp/purchase-requisition'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createPurchaseOrder, getPurchaseOrder, updatePurchaseOrder } from '@/api/erp/purchase-order'
|
||||
import { getProductSimpleList } from '@/api/erp/product'
|
||||
import { getSupplierSimpleList } from '@/api/erp/supplier'
|
||||
import { getPurchaseRequisition, getPurchaseRequisitionPage } from '@/api/erp/purchase-requisition'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const toast = useToast()
|
||||
const getTitle = computed(() => props.id ? '编辑采购订单' : '新增采购订单')
|
||||
const formLoading = ref(false)
|
||||
const formData = ref<PurchaseOrder>({
|
||||
id: undefined,
|
||||
purchaseRequisitionId: undefined,
|
||||
purchaseRequisitionNo: undefined,
|
||||
supplierId: undefined,
|
||||
orderTime: undefined,
|
||||
discountPercent: undefined,
|
||||
depositPrice: undefined,
|
||||
invoiceType: undefined,
|
||||
freightPayer: undefined,
|
||||
settlementMethod: undefined,
|
||||
remark: '',
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
supplierId: [{ required: true, message: '供应商不能为空' }],
|
||||
orderTime: [{ required: true, message: '采购时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
const supplierList = ref<SupplierSimple[]>([])
|
||||
const productList = ref<ProductSimple[]>([])
|
||||
const requisitionList = ref<PurchaseRequisition[]>([])
|
||||
const requisitionPickerVisible = ref(false)
|
||||
const requisitionLoading = ref(false)
|
||||
|
||||
/** 供应商下拉列 */
|
||||
const supplierColumns = computed(() => [
|
||||
supplierList.value.map(s => ({ value: s.id, label: s.name })),
|
||||
])
|
||||
|
||||
/** 产品下拉列 */
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(p => ({ value: p.id, label: p.name })),
|
||||
])
|
||||
|
||||
/** 供应商选择回调 */
|
||||
function onSupplierConfirm({ value }: any) {
|
||||
formData.value.supplierId = value?.[0]
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateVal?: string | number) {
|
||||
if (!dateVal) return '-'
|
||||
if (typeof dateVal === 'number') {
|
||||
const d = new Date(dateVal)
|
||||
const pad = (n: number) => n.toString().padStart(2, '0')
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
|
||||
}
|
||||
return String(dateVal).substring(0, 10)
|
||||
}
|
||||
|
||||
/** 打开请购单选择弹窗 */
|
||||
async function openRequisitionPicker() {
|
||||
requisitionPickerVisible.value = true
|
||||
requisitionLoading.value = true
|
||||
try {
|
||||
const res = await getPurchaseRequisitionPage({ pageNo: 1, pageSize: 50, status: 2 })
|
||||
requisitionList.value = res.list || []
|
||||
} finally {
|
||||
requisitionLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 请购单选择回调:带出税率税额等信息 */
|
||||
async function onRequisitionSelect(requisition: PurchaseRequisition) {
|
||||
requisitionPickerVisible.value = false
|
||||
formData.value.purchaseRequisitionId = requisition.id
|
||||
formData.value.purchaseRequisitionNo = requisition.no
|
||||
|
||||
// 自动填充供应商
|
||||
if (requisition.supplierId) {
|
||||
formData.value.supplierId = requisition.supplierId
|
||||
}
|
||||
|
||||
try {
|
||||
toast.loading('加载请购单明细...')
|
||||
// 获取请购单详情(包含明细项)
|
||||
const detail = await getPurchaseRequisition(requisition.id!)
|
||||
|
||||
// 转换请购单明细为采购订单明细(带上税率和税额)
|
||||
const orderItems: PurchaseOrderItem[] = (detail.items || []).map(item => ({
|
||||
productId: item.productId,
|
||||
productName: item.productName,
|
||||
productSpec: item.productSpec,
|
||||
productUnitId: item.productUnitId,
|
||||
productUnitName: item.productUnitName,
|
||||
productBarCode: item.productBarCode,
|
||||
productPrice: item.productPrice,
|
||||
count: item.count,
|
||||
totalProductPrice: item.totalProductPrice || item.totalPrice,
|
||||
taxPercent: item.taxPercent || 0,
|
||||
taxPrice: item.taxPrice || 0,
|
||||
totalPrice: item.totalPrice,
|
||||
supplierId: item.supplierId,
|
||||
supplierName: item.supplierName,
|
||||
remark: item.remark,
|
||||
}))
|
||||
|
||||
formData.value.items = orderItems
|
||||
|
||||
// 带上备注
|
||||
if (detail.remark) {
|
||||
formData.value.remark = `基于请购单 ${detail.no} 生成\n${detail.remark}`
|
||||
}
|
||||
|
||||
toast.success('已导入请购单明细')
|
||||
} catch {
|
||||
toast.error('获取请购单详情失败')
|
||||
}
|
||||
}
|
||||
|
||||
/** 产品选择回调:自动填充规格/单位/条码/单价/供应商 */
|
||||
function onProductConfirm({ value }: any, index: number) {
|
||||
const productId = value?.[0]
|
||||
if (formData.value.items && formData.value.items[index]) {
|
||||
const item = formData.value.items[index]
|
||||
item.productId = productId
|
||||
const product = productList.value.find(p => p.id === productId)
|
||||
if (product) {
|
||||
item.productName = product.name
|
||||
item.productSpec = product.standard || ''
|
||||
item.productUnitName = product.unitName || ''
|
||||
item.productUnitId = product.unitId as any
|
||||
item.productBarCode = product.barCode || ''
|
||||
item.productPrice = product.purchasePrice
|
||||
item.supplierId = product.supplierId
|
||||
item.supplierName = product.supplierName || ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算行项金额 */
|
||||
function calcTotalPrice(item: PurchaseOrderItem) {
|
||||
if (item.productPrice && item.count) {
|
||||
const total = Number(item.productPrice) * Number(item.count)
|
||||
return `¥${total.toFixed(2)}`
|
||||
}
|
||||
return '-'
|
||||
}
|
||||
|
||||
/** 加载下拉列表数据 */
|
||||
async function loadDropdownData() {
|
||||
try {
|
||||
const [suppliers, products] = await Promise.all([
|
||||
getSupplierSimpleList(),
|
||||
getProductSimpleList(),
|
||||
])
|
||||
supplierList.value = suppliers || []
|
||||
productList.value = products || []
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/purchase-order/index')
|
||||
}
|
||||
|
||||
/** 添加订单明细行 */
|
||||
function handleAddItem() {
|
||||
if (!formData.value.items) {
|
||||
formData.value.items = []
|
||||
}
|
||||
formData.value.items.push({
|
||||
productId: undefined as any,
|
||||
productName: undefined as any,
|
||||
productUnitId: undefined as any,
|
||||
productUnitName: undefined as any,
|
||||
productPrice: undefined,
|
||||
productSpec: undefined as any,
|
||||
productBarCode: undefined as any,
|
||||
count: 1 as any,
|
||||
taxPercent: undefined,
|
||||
supplierId: undefined,
|
||||
supplierName: undefined as any,
|
||||
remark: '',
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除订单明细行 */
|
||||
function handleRemoveItem(index: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `确定要删除第 ${index + 1} 项产品吗?`,
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
formData.value = await getPurchaseOrder(props.id)
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) {
|
||||
return
|
||||
}
|
||||
// 校验订单明细
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.warning('请至少添加一项产品明细')
|
||||
return
|
||||
}
|
||||
for (let i = 0; i < formData.value.items.length; i++) {
|
||||
const item = formData.value.items[i]
|
||||
if (!item.productId) {
|
||||
toast.warning(`第 ${i + 1} 项产品ID不能为空`)
|
||||
return
|
||||
}
|
||||
if (!item.count) {
|
||||
toast.warning(`第 ${i + 1} 项产品数量不能为空`)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
if (props.id) {
|
||||
await updatePurchaseOrder(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createPurchaseOrder(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
await loadDropdownData()
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
344
src/pages-erp/purchase-order/index.vue
Normal file
344
src/pages-erp/purchase-order/index.vue
Normal file
@@ -0,0 +1,344 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采购订单"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<SearchForm @search="handleQuery" @reset="handleReset" />
|
||||
|
||||
<!-- 状态快速筛选 -->
|
||||
<view class="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
: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]"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 采购订单列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
@click="handleCardClick(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:单号 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.no }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getStatusClass(item.status)"
|
||||
>
|
||||
{{ getStatusText(item.status) }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 供应商 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">供应商</text>
|
||||
<text>{{ item.supplierName || '-' }}</text>
|
||||
</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>
|
||||
</view>
|
||||
<!-- 订单时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">订单时间</text>
|
||||
<text>{{ formatDate(item.orderTime) }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<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>
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#52c41a] font-semibold">{{ item.inCount || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">已入库</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>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:query'])"
|
||||
size="small" plain @click="handleDetail(item)"
|
||||
>
|
||||
详情
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:update']) && item.status !== 20"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleUpdateStatus(item.id!, 20)"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:update-status']) && item.status === 20"
|
||||
size="small" type="error" plain @click="handleUpdateStatus(item.id!, 10)"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:delete']) && item.status !== 20"
|
||||
size="small" type="error" plain @click="handleDelete(item.id!)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无采购订单数据" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 新增按钮 -->
|
||||
<wd-fab
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PurchaseOrder } from '@/api/erp/purchase-order'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deletePurchaseOrder, getPurchaseOrderPage, updatePurchaseOrderStatus } from '@/api/erp/purchase-order'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
import SearchForm from './components/search-form.vue'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<PurchaseOrder[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const activeStatus = ref<number | undefined>(undefined)
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
const statusTabs = [
|
||||
{ label: '全部', value: undefined },
|
||||
{ label: '待审核', value: 10 },
|
||||
{ label: '已审核', value: 20 },
|
||||
]
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(date?: string) {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleDateString('zh-CN')
|
||||
}
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number) {
|
||||
switch (status) {
|
||||
case 10: return '未审批'
|
||||
case 20: return '已审批'
|
||||
case 30: return '已驳回'
|
||||
default: return '未知'
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number) {
|
||||
switch (status) {
|
||||
case 10: return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
case 20: return 'bg-[#f6ffed] text-[#52c41a]'
|
||||
case 30: return 'bg-[#fff1f0] text-[#f5222d]'
|
||||
default: return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询采购订单列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
const data = await getPurchaseOrderPage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 状态快速筛选 */
|
||||
function handleQuickFilter(status?: number) {
|
||||
activeStatus.value = status
|
||||
queryParams.value.status = status
|
||||
queryParams.value.pageNo = 1
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery(data?: Record<string, any>) {
|
||||
queryParams.value = {
|
||||
...data,
|
||||
status: activeStatus.value,
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function handleReset() {
|
||||
activeStatus.value = undefined
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') {
|
||||
return
|
||||
}
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 卡片点击 — 已审核打开详情,未审核打开编辑 */
|
||||
function handleCardClick(item: PurchaseOrder) {
|
||||
if (item.status === 20) {
|
||||
handleDetail(item)
|
||||
} else if (item.status === 10) {
|
||||
handleEdit(item)
|
||||
}
|
||||
}
|
||||
|
||||
/** 新增采购订单 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({
|
||||
url: '/pages-erp/purchase-order/form/index',
|
||||
})
|
||||
}
|
||||
|
||||
/** 查看详情 */
|
||||
function handleDetail(item: PurchaseOrder) {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-order/detail/index?id=${item.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: PurchaseOrder) {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-order/form/index?id=${item.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 审批/反审批 */
|
||||
function handleUpdateStatus(id: number, status: number) {
|
||||
const text = status === 20 ? '审批' : '反审批'
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `确定${text}该订单吗?`,
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePurchaseOrderStatus(id, status)
|
||||
toast.success(`${text}成功`)
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该采购订单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deletePurchaseOrder([id])
|
||||
toast.success('删除成功')
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
374
src/pages-erp/purchase-requisition/detail/index.vue
Normal file
374
src/pages-erp/purchase-requisition/detail/index.vue
Normal file
@@ -0,0 +1,374 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="请购单详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view class="pb-180rpx">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="请购单号" :value="detail.no || '-'" />
|
||||
<wd-cell title="请购类型">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-2rpx text-22rpx"
|
||||
:class="getTypeClass(detail.type)"
|
||||
>
|
||||
{{ getTypeLabel(detail.type) }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="状态">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-2rpx text-22rpx"
|
||||
:class="getStatusClass(detail.status)"
|
||||
>
|
||||
{{ getStatusLabel(detail.status) }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="优先级">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-2rpx text-22rpx"
|
||||
:class="getPriorityClass(detail.priority)"
|
||||
>
|
||||
{{ getPriorityLabel(detail.priority) }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="紧急程度">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-2rpx text-22rpx"
|
||||
:class="getEmergencyClass(detail.emergencyDegree)"
|
||||
>
|
||||
{{ getEmergencyLabel(detail.emergencyDegree) }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="请购人" :value="detail.requesterNickname || '-'" />
|
||||
<wd-cell title="请购部门" :value="detail.requesterDeptName || '-'" />
|
||||
<wd-cell title="请购时间" :value="formatDate(detail.requestTime)" />
|
||||
<wd-cell title="期望到货" :value="formatDate(detail.expectedTime)" />
|
||||
<wd-cell title="备注" :value="detail.remark || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(detail.totalCount)" />
|
||||
<wd-cell title="合计产品金额" :value="formatPrice(detail.totalProductPrice)" />
|
||||
<wd-cell title="合计税额" :value="formatPrice(detail.totalTaxPrice)" />
|
||||
<wd-cell title="合计金额(含税)" :value="formatPrice(detail.totalPrice)" />
|
||||
<wd-cell title="附加费" :value="formatPrice(detail.additionalFee)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 审核信息 -->
|
||||
<wd-cell-group v-if="detail.status !== 1" title="审核信息" border>
|
||||
<wd-cell title="审核人" :value="detail.approverName || '-'" />
|
||||
<wd-cell title="审核时间" :value="formatDateTime(detail.approveTime)" />
|
||||
<wd-cell title="审核意见" :value="detail.approveRemark || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 请购产品清单 -->
|
||||
<wd-cell-group title="请购产品清单" border>
|
||||
<view v-if="!detail.items || detail.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品数据
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in detail.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '-' }}
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">规格</text>
|
||||
<text class="text-[#666]">{{ item.productSpec || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">单位</text>
|
||||
<text class="text-[#666]">{{ item.productUnitName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">需求数量</text>
|
||||
<text class="text-[#333] font-semibold">{{ formatCount(item.count) }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">参考单价</text>
|
||||
<text class="text-[#666]">{{ formatPrice(item.productPrice) }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">产品金额</text>
|
||||
<text class="text-[#666]">{{ formatPrice(item.totalProductPrice) }}</text>
|
||||
</view>
|
||||
<view v-if="item.taxPercent" class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">税率</text>
|
||||
<text class="text-[#666]">{{ item.taxPercent }}%</text>
|
||||
</view>
|
||||
<view v-if="item.taxPrice" class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">税额</text>
|
||||
<text class="text-[#666]">{{ formatPrice(item.taxPrice) }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">含税金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
<view v-if="item.supplierName" class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">建议供应商</text>
|
||||
<text class="text-[#666]">{{ item.supplierName }}</text>
|
||||
</view>
|
||||
<view v-if="item.purpose" class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">用途</text>
|
||||
<text class="text-[#666]">{{ item.purpose }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:update']) && detail.status === 1"
|
||||
type="primary"
|
||||
@click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:update-status']) && detail.status === 1"
|
||||
type="success"
|
||||
@click="handleApprove"
|
||||
>
|
||||
审核
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:approve']) && detail.status === 1"
|
||||
type="warning"
|
||||
@click="handleReject"
|
||||
>
|
||||
驳回
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:delete']) && detail.status === 1"
|
||||
type="error"
|
||||
@click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PurchaseRequisition } from '@/api/erp/purchase-requisition'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import {
|
||||
deletePurchaseRequisition,
|
||||
EMERGENCY_OPTIONS,
|
||||
getPurchaseRequisition,
|
||||
PRIORITY_OPTIONS,
|
||||
REQUISITION_TYPE_OPTIONS,
|
||||
STATUS_OPTIONS,
|
||||
updatePurchaseRequisitionStatus,
|
||||
} from '@/api/erp/purchase-requisition'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const detail = ref<PurchaseRequisition>({})
|
||||
|
||||
/** 获取类型标签 */
|
||||
function getTypeLabel(type?: number) {
|
||||
return REQUISITION_TYPE_OPTIONS.find(o => o.value === type)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取类型样式 */
|
||||
function getTypeClass(type?: number) {
|
||||
const map: Record<number, string> = {
|
||||
1: 'bg-[#e6f7ff] text-[#1890ff]',
|
||||
2: 'bg-[#fff7e6] text-[#fa8c16]',
|
||||
3: 'bg-[#f9f0ff] text-[#722ed1]',
|
||||
}
|
||||
return map[type || 1] || 'bg-[#f5f5f5] text-[#666]'
|
||||
}
|
||||
|
||||
/** 获取状态标签 */
|
||||
function getStatusLabel(status?: number) {
|
||||
return STATUS_OPTIONS.find(o => o.value === status)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number) {
|
||||
const map: Record<number, string> = {
|
||||
1: 'bg-[#fff7e6] text-[#fa8c16]',
|
||||
2: 'bg-[#f6ffed] text-[#52c41a]',
|
||||
3: 'bg-[#fff1f0] text-[#f5222d]',
|
||||
4: 'bg-[#f5f5f5] text-[#999]',
|
||||
5: 'bg-[#e6f7ff] text-[#1890ff]',
|
||||
}
|
||||
return map[status || 1] || 'bg-[#f5f5f5] text-[#666]'
|
||||
}
|
||||
|
||||
/** 获取优先级标签 */
|
||||
function getPriorityLabel(priority?: number) {
|
||||
return PRIORITY_OPTIONS.find(o => o.value === priority)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取优先级样式 */
|
||||
function getPriorityClass(priority?: number) {
|
||||
const map: Record<number, string> = {
|
||||
1: 'bg-[#f5f5f5] text-[#999]',
|
||||
2: 'bg-[#e6f7ff] text-[#1890ff]',
|
||||
3: 'bg-[#fff7e6] text-[#fa8c16]',
|
||||
4: 'bg-[#fff1f0] text-[#f5222d]',
|
||||
}
|
||||
return map[priority || 1] || 'bg-[#f5f5f5] text-[#666]'
|
||||
}
|
||||
|
||||
/** 获取紧急程度标签 */
|
||||
function getEmergencyLabel(emergency?: number) {
|
||||
return EMERGENCY_OPTIONS.find(o => o.value === emergency)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取紧急程度样式 */
|
||||
function getEmergencyClass(emergency?: number) {
|
||||
const map: Record<number, string> = {
|
||||
1: 'bg-[#f5f5f5] text-[#999]',
|
||||
2: 'bg-[#e6f7ff] text-[#1890ff]',
|
||||
3: 'bg-[#fff7e6] text-[#fa8c16]',
|
||||
4: 'bg-[#fff1f0] text-[#f5222d]',
|
||||
}
|
||||
return map[emergency || 1] || 'bg-[#f5f5f5] text-[#666]'
|
||||
}
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 格式化日期时间 */
|
||||
function formatDateTime(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 16).replace('T', ' ')
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/purchase-requisition/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
detail.value = await getPurchaseRequisition(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({ url: `/pages-erp/purchase-requisition/form/index?id=${props.id}` })
|
||||
}
|
||||
|
||||
/** 审核 */
|
||||
function handleApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审核通过该请购单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePurchaseRequisitionStatus(props.id, 2)
|
||||
toast.success('审核成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 驳回 */
|
||||
function handleReject() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要驳回该请购单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePurchaseRequisitionStatus(props.id, 3)
|
||||
toast.success('驳回成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该请购单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deletePurchaseRequisition(props.id)
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
517
src/pages-erp/purchase-requisition/form/index.vue
Normal file
517
src/pages-erp/purchase-requisition/form/index.vue
Normal file
@@ -0,0 +1,517 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="请购单号" :value="formData.no || '保存时自动生成'" />
|
||||
<wd-cell
|
||||
title="请购类型"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="getTypeLabel(formData.type)"
|
||||
@click="typePickerVisible = true"
|
||||
/>
|
||||
<wd-cell
|
||||
title="优先级"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="getPriorityLabel(formData.priority)"
|
||||
@click="priorityPickerVisible = true"
|
||||
/>
|
||||
<wd-cell
|
||||
title="紧急程度"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="getEmergencyLabel(formData.emergencyDegree)"
|
||||
@click="emergencyPickerVisible = true"
|
||||
/>
|
||||
<wd-cell
|
||||
title="请购时间"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="formData.requestTime ? formatDate(formData.requestTime) : '请选择'"
|
||||
@click="requestDatePickerVisible = true"
|
||||
/>
|
||||
<wd-cell
|
||||
title="期望到货"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="formData.expectedTime ? formatDate(formData.expectedTime) : '请选择'"
|
||||
@click="expectedDatePickerVisible = true"
|
||||
/>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 请购产品清单 -->
|
||||
<wd-cell-group title="请购产品清单" border>
|
||||
<view v-if="formData.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品,请点击下方按钮添加
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '请选择产品' }}
|
||||
</view>
|
||||
<wd-icon name="delete" size="40rpx" color="#f56c6c" @click="removeItem(index)" />
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="产品"
|
||||
title-width="140rpx"
|
||||
is-link
|
||||
:value="item.productName || '请选择'"
|
||||
@click="openProductPicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.count"
|
||||
label="需求数量"
|
||||
label-width="140rpx"
|
||||
type="number"
|
||||
placeholder="请输入数量"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
label="参考单价"
|
||||
label-width="140rpx"
|
||||
type="digit"
|
||||
placeholder="请输入单价"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">产品金额</text>
|
||||
<text class="text-[#666]">{{ formatPrice(item.totalProductPrice) }}</text>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.taxPercent"
|
||||
label="税率(%)"
|
||||
label-width="140rpx"
|
||||
type="digit"
|
||||
placeholder="请输入税率"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">税额</text>
|
||||
<text class="text-[#666]">{{ formatPrice(item.taxPrice) }}</text>
|
||||
</view>
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">含税金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.purpose"
|
||||
label="用途说明"
|
||||
label-width="140rpx"
|
||||
placeholder="请输入用途"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.remark"
|
||||
label="备注"
|
||||
label-width="140rpx"
|
||||
placeholder="请输入备注"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="px-24rpx pb-24rpx">
|
||||
<wd-button type="primary" plain block @click="addItem">
|
||||
<wd-icon name="add" class="mr-8rpx" />
|
||||
添加产品
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 合计信息 -->
|
||||
<wd-cell-group title="合计信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(totalCount)" />
|
||||
<wd-cell title="合计产品金额" :value="formatPrice(totalProductPrice)" />
|
||||
<wd-cell title="合计税额" :value="formatPrice(totalTaxPrice)" />
|
||||
<wd-cell title="合计金额(含税)" :value="formatPrice(totalPrice)" />
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 请购类型选择器 -->
|
||||
<wd-picker
|
||||
v-model="typePickerVisible"
|
||||
:columns="typeColumns"
|
||||
@confirm="onTypeConfirm"
|
||||
/>
|
||||
|
||||
<!-- 优先级选择器 -->
|
||||
<wd-picker
|
||||
v-model="priorityPickerVisible"
|
||||
:columns="priorityColumns"
|
||||
@confirm="onPriorityConfirm"
|
||||
/>
|
||||
|
||||
<!-- 紧急程度选择器 -->
|
||||
<wd-picker
|
||||
v-model="emergencyPickerVisible"
|
||||
:columns="emergencyColumns"
|
||||
@confirm="onEmergencyConfirm"
|
||||
/>
|
||||
|
||||
<!-- 请购时间选择器 -->
|
||||
<wd-datetime-picker
|
||||
v-model="requestDatePickerVisible"
|
||||
type="date"
|
||||
:value="formData.requestTime"
|
||||
@confirm="onRequestDateConfirm"
|
||||
/>
|
||||
|
||||
<!-- 期望到货选择器 -->
|
||||
<wd-datetime-picker
|
||||
v-model="expectedDatePickerVisible"
|
||||
type="date"
|
||||
:value="formData.expectedTime"
|
||||
@confirm="onExpectedDateConfirm"
|
||||
/>
|
||||
|
||||
<!-- 产品选择器 -->
|
||||
<wd-picker
|
||||
v-model="productPickerVisible"
|
||||
:columns="productColumns"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { PurchaseRequisition, PurchaseRequisitionItem } from '@/api/erp/purchase-requisition'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import {
|
||||
createPurchaseRequisition,
|
||||
EMERGENCY_OPTIONS,
|
||||
getPurchaseRequisition,
|
||||
PRIORITY_OPTIONS,
|
||||
REQUISITION_TYPE_OPTIONS,
|
||||
updatePurchaseRequisition,
|
||||
} from '@/api/erp/purchase-requisition'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const toast = useToast()
|
||||
const getTitle = computed(() => props.id ? '编辑请购单' : '新增请购单')
|
||||
const formLoading = ref(false)
|
||||
const formData = ref<PurchaseRequisition>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
type: 1,
|
||||
priority: 2,
|
||||
emergencyDegree: 1,
|
||||
requestTime: undefined,
|
||||
expectedTime: undefined,
|
||||
remark: undefined,
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
type: [{ required: true, message: '请购类型不能为空' }],
|
||||
requestTime: [{ required: true, message: '请购时间不能为空' }],
|
||||
expectedTime: [{ required: true, message: '期望到货时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 类型选择器
|
||||
const typePickerVisible = ref(false)
|
||||
const typeColumns = computed(() => [
|
||||
REQUISITION_TYPE_OPTIONS.map(v => ({ value: v.value, label: v.label })),
|
||||
])
|
||||
|
||||
// 优先级选择器
|
||||
const priorityPickerVisible = ref(false)
|
||||
const priorityColumns = computed(() => [
|
||||
PRIORITY_OPTIONS.map(v => ({ value: v.value, label: v.label })),
|
||||
])
|
||||
|
||||
// 紧急程度选择器
|
||||
const emergencyPickerVisible = ref(false)
|
||||
const emergencyColumns = computed(() => [
|
||||
EMERGENCY_OPTIONS.map(v => ({ value: v.value, label: v.label })),
|
||||
])
|
||||
|
||||
// 日期选择器
|
||||
const requestDatePickerVisible = ref(false)
|
||||
const expectedDatePickerVisible = ref(false)
|
||||
|
||||
// 产品列表
|
||||
const productList = ref<{ id: number, name: string, unitName?: string }[]>([])
|
||||
const productPickerVisible = ref(false)
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 当前编辑的产品项索引
|
||||
const currentItemIndex = ref(-1)
|
||||
|
||||
/** 合计数量 */
|
||||
const totalCount = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.count) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计产品金额 */
|
||||
const totalProductPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.totalProductPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计税额 */
|
||||
const totalTaxPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.taxPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计金额(含税) */
|
||||
const totalPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.totalPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 获取类型标签 */
|
||||
function getTypeLabel(type?: number) {
|
||||
return REQUISITION_TYPE_OPTIONS.find(o => o.value === type)?.label || '请选择'
|
||||
}
|
||||
|
||||
/** 获取优先级标签 */
|
||||
function getPriorityLabel(priority?: number) {
|
||||
return PRIORITY_OPTIONS.find(o => o.value === priority)?.label || '请选择'
|
||||
}
|
||||
|
||||
/** 获取紧急程度标签 */
|
||||
function getEmergencyLabel(emergency?: number) {
|
||||
return EMERGENCY_OPTIONS.find(o => o.value === emergency)?.label || '请选择'
|
||||
}
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
if (typeof dateStr === 'number') {
|
||||
const d = new Date(dateStr)
|
||||
const pad = (n: number) => n.toString().padStart(2, '0')
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
|
||||
}
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/purchase-requisition/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getPurchaseRequisition(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 类型确认 */
|
||||
function onTypeConfirm({ value }: any) {
|
||||
formData.value.type = value?.[0]
|
||||
typePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 优先级确认 */
|
||||
function onPriorityConfirm({ value }: any) {
|
||||
formData.value.priority = value?.[0]
|
||||
priorityPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 紧急程度确认 */
|
||||
function onEmergencyConfirm({ value }: any) {
|
||||
formData.value.emergencyDegree = value?.[0]
|
||||
emergencyPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 请购时间确认 */
|
||||
function onRequestDateConfirm({ value }: any) {
|
||||
formData.value.requestTime = value
|
||||
requestDatePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 期望到货确认 */
|
||||
function onExpectedDateConfirm({ value }: any) {
|
||||
formData.value.expectedTime = value
|
||||
expectedDatePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开产品选择器 */
|
||||
function openProductPicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
productPickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 产品确认 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.productId = value?.[0]
|
||||
const product = productList.value.find(p => p.id === item.productId)
|
||||
item.productName = product?.name
|
||||
item.productUnitName = product?.unitName
|
||||
}
|
||||
productPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 添加产品项 */
|
||||
function addItem() {
|
||||
if (!formData.value.items) {
|
||||
formData.value.items = []
|
||||
}
|
||||
formData.value.items.push({
|
||||
productId: undefined,
|
||||
productName: undefined,
|
||||
productUnitName: undefined,
|
||||
count: undefined,
|
||||
productPrice: undefined,
|
||||
totalProductPrice: 0,
|
||||
taxPercent: undefined,
|
||||
taxPrice: 0,
|
||||
totalPrice: 0,
|
||||
purpose: undefined,
|
||||
remark: undefined,
|
||||
})
|
||||
}
|
||||
|
||||
/** 移除产品项 */
|
||||
function removeItem(index: number) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 计算产品项金额(含税) */
|
||||
function calcItemTotal(item: PurchaseRequisitionItem) {
|
||||
const count = Number(item.count) || 0
|
||||
const price = Number(item.productPrice) || 0
|
||||
const taxPercent = Number(item.taxPercent) || 0
|
||||
// 产品金额 = 单价 × 数量
|
||||
const totalProductPrice = count * price
|
||||
// 税额 = 产品金额 × 税率 / 100
|
||||
const taxPrice = totalProductPrice * taxPercent / 100
|
||||
// 含税金额 = 产品金额 + 税额
|
||||
item.totalProductPrice = Math.round(totalProductPrice * 100) / 100
|
||||
item.taxPrice = Math.round(taxPrice * 100) / 100
|
||||
item.totalPrice = Math.round((totalProductPrice + taxPrice) * 100) / 100
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
// 校验产品清单
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.error('请添加请购产品')
|
||||
return
|
||||
}
|
||||
|
||||
for (const item of formData.value.items) {
|
||||
if (!item.productId) {
|
||||
toast.error('请选择产品')
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.error('请输入有效的数量')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
// 设置合计
|
||||
formData.value.totalCount = totalCount.value
|
||||
formData.value.totalProductPrice = totalProductPrice.value
|
||||
formData.value.totalTaxPrice = totalTaxPrice.value
|
||||
formData.value.totalPrice = totalPrice.value
|
||||
|
||||
if (props.id) {
|
||||
await updatePurchaseRequisition(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createPurchaseRequisition(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
// 加载详情
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
515
src/pages-erp/purchase-requisition/index.vue
Normal file
515
src/pages-erp/purchase-requisition/index.vue
Normal file
@@ -0,0 +1,515 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采购申请"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<view @click="searchVisible = true">
|
||||
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 快捷筛选标签 -->
|
||||
<view class="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
:class="queryParams.status === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'"
|
||||
@click="onTabChange(tab.value)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<view
|
||||
v-if="queryParams.status === tab.value"
|
||||
class="absolute bottom-0 left-1/4 w-1/2 h-4rpx rounded-2rpx bg-[#1890ff]"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 请购单列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
@click="handleDetail(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:单号 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.no || '-' }}
|
||||
</view>
|
||||
<view class="flex items-center gap-8rpx">
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-4rpx text-22rpx"
|
||||
:class="getTypeClass(item.type)"
|
||||
>
|
||||
{{ getTypeLabel(item.type) }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-4rpx text-22rpx"
|
||||
:class="getStatusClass(item.status)"
|
||||
>
|
||||
{{ getStatusLabel(item.status) }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 优先级 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">优先级</text>
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-2rpx text-22rpx"
|
||||
:class="getPriorityClass(item.priority)"
|
||||
>
|
||||
{{ getPriorityLabel(item.priority) }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 请购人 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">请购人</text>
|
||||
<text>{{ item.requesterNickname || '-' }}</text>
|
||||
</view>
|
||||
<!-- 请购部门 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">请购部门</text>
|
||||
<text>{{ item.requesterDeptName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 请购时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">请购时间</text>
|
||||
<text>{{ formatDate(item.requestTime) }}</text>
|
||||
</view>
|
||||
<!-- 期望到货 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">期望到货</text>
|
||||
<text>{{ formatDate(item.expectedTime) }}</text>
|
||||
</view>
|
||||
<!-- 紧急程度 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">紧急程度</text>
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-2rpx text-22rpx"
|
||||
:class="getEmergencyClass(item.emergencyDegree)"
|
||||
>
|
||||
{{ getEmergencyLabel(item.emergencyDegree) }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#333] font-semibold">{{ formatCount(item.totalCount) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">总数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">总金额</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:update']) && item.status === 1"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:update-status']) && item.status === 1"
|
||||
size="small" type="success" plain @click="handleApprove(item.id!)"
|
||||
>
|
||||
审核
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:approve']) && item.status === 1"
|
||||
size="small" type="warning" plain @click="handleReject(item.id!)"
|
||||
>
|
||||
驳回
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:delete']) && item.status === 1"
|
||||
size="small" type="error" plain @click="handleDelete(item.id!)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无请购单数据" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 新增按钮 -->
|
||||
<wd-fab
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">请购单号</view>
|
||||
<wd-input v-model="searchForm.no" placeholder="请输入请购单号" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">请购类型</view>
|
||||
<view class="yd-search-form-radio-group">
|
||||
<view
|
||||
v-for="opt in typeOptions"
|
||||
:key="opt.value"
|
||||
class="yd-search-form-radio"
|
||||
:class="{ 'yd-search-form-radio--active': searchForm.type === opt.value }"
|
||||
@click="searchForm.type = opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">状态</view>
|
||||
<view class="yd-search-form-radio-group">
|
||||
<view
|
||||
v-for="opt in statusOptions"
|
||||
:key="opt.value"
|
||||
class="yd-search-form-radio"
|
||||
:class="{ 'yd-search-form-radio--active': searchForm.status === opt.value }"
|
||||
@click="searchForm.status = opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">重置</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">搜索</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PurchaseRequisition } from '@/api/erp/purchase-requisition'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import {
|
||||
deletePurchaseRequisition,
|
||||
EMERGENCY_OPTIONS,
|
||||
getPurchaseRequisitionPage,
|
||||
PRIORITY_OPTIONS,
|
||||
REQUISITION_TYPE_OPTIONS,
|
||||
STATUS_OPTIONS,
|
||||
updatePurchaseRequisitionStatus,
|
||||
} from '@/api/erp/purchase-requisition'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<PurchaseRequisition[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
status: undefined,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
no: undefined as string | undefined,
|
||||
type: undefined as number | undefined,
|
||||
status: undefined as number | undefined,
|
||||
})
|
||||
|
||||
/** 状态标签 */
|
||||
const statusTabs = [
|
||||
{ value: undefined, label: '全部' },
|
||||
{ value: 1, label: '待审核' },
|
||||
{ value: 2, label: '已审核' },
|
||||
{ value: 5, label: '已采购' },
|
||||
]
|
||||
|
||||
/** 类型选项 */
|
||||
const typeOptions = [
|
||||
{ value: undefined, label: '全部' },
|
||||
...REQUISITION_TYPE_OPTIONS,
|
||||
]
|
||||
|
||||
/** 状态选项 */
|
||||
const statusOptions = [
|
||||
{ value: undefined, label: '全部' },
|
||||
...STATUS_OPTIONS,
|
||||
]
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.no) conditions.push(`单号:${searchForm.no}`)
|
||||
if (searchForm.type !== undefined) {
|
||||
const typeLabel = REQUISITION_TYPE_OPTIONS.find(o => o.value === searchForm.type)?.label
|
||||
if (typeLabel) conditions.push(`类型:${typeLabel}`)
|
||||
}
|
||||
if (searchForm.status !== undefined) {
|
||||
const statusLabel = STATUS_OPTIONS.find(o => o.value === searchForm.status)?.label
|
||||
if (statusLabel) conditions.push(`状态:${statusLabel}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索请购单'
|
||||
})
|
||||
|
||||
/** 获取类型标签 */
|
||||
function getTypeLabel(type?: number) {
|
||||
return REQUISITION_TYPE_OPTIONS.find(o => o.value === type)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取类型样式 */
|
||||
function getTypeClass(type?: number) {
|
||||
const map: Record<number, string> = {
|
||||
1: 'bg-[#e6f7ff] text-[#1890ff]',
|
||||
2: 'bg-[#fff7e6] text-[#fa8c16]',
|
||||
3: 'bg-[#f9f0ff] text-[#722ed1]',
|
||||
}
|
||||
return map[type || 1] || 'bg-[#f5f5f5] text-[#666]'
|
||||
}
|
||||
|
||||
/** 获取状态标签 */
|
||||
function getStatusLabel(status?: number) {
|
||||
return STATUS_OPTIONS.find(o => o.value === status)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number) {
|
||||
const map: Record<number, string> = {
|
||||
1: 'bg-[#fff7e6] text-[#fa8c16]',
|
||||
2: 'bg-[#f6ffed] text-[#52c41a]',
|
||||
3: 'bg-[#fff1f0] text-[#f5222d]',
|
||||
4: 'bg-[#f5f5f5] text-[#999]',
|
||||
5: 'bg-[#e6f7ff] text-[#1890ff]',
|
||||
}
|
||||
return map[status || 1] || 'bg-[#f5f5f5] text-[#666]'
|
||||
}
|
||||
|
||||
/** 获取优先级标签 */
|
||||
function getPriorityLabel(priority?: number) {
|
||||
return PRIORITY_OPTIONS.find(o => o.value === priority)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取优先级样式 */
|
||||
function getPriorityClass(priority?: number) {
|
||||
const map: Record<number, string> = {
|
||||
1: 'bg-[#f5f5f5] text-[#999]',
|
||||
2: 'bg-[#e6f7ff] text-[#1890ff]',
|
||||
3: 'bg-[#fff7e6] text-[#fa8c16]',
|
||||
4: 'bg-[#fff1f0] text-[#f5222d]',
|
||||
}
|
||||
return map[priority || 1] || 'bg-[#f5f5f5] text-[#666]'
|
||||
}
|
||||
|
||||
/** 获取紧急程度标签 */
|
||||
function getEmergencyLabel(emergency?: number) {
|
||||
return EMERGENCY_OPTIONS.find(o => o.value === emergency)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取紧急程度样式 */
|
||||
function getEmergencyClass(emergency?: number) {
|
||||
const map: Record<number, string> = {
|
||||
1: 'bg-[#f5f5f5] text-[#999]',
|
||||
2: 'bg-[#e6f7ff] text-[#1890ff]',
|
||||
3: 'bg-[#fff7e6] text-[#fa8c16]',
|
||||
4: 'bg-[#fff1f0] text-[#f5222d]',
|
||||
}
|
||||
return map[emergency || 1] || 'bg-[#f5f5f5] text-[#666]'
|
||||
}
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 切换状态标签 */
|
||||
function onTabChange(status: number | undefined) {
|
||||
queryParams.value.status = status
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 查询请购单列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
if (searchForm.no) params.no = searchForm.no
|
||||
if (searchForm.type !== undefined) params.type = searchForm.type
|
||||
const data = await getPurchaseRequisitionPage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
searchVisible.value = false
|
||||
queryParams.value = {
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
status: searchForm.status,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.no = undefined
|
||||
searchForm.type = undefined
|
||||
searchForm.status = undefined
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10, status: undefined }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 新增请购单 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/purchase-requisition/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: PurchaseRequisition) {
|
||||
uni.navigateTo({ url: `/pages-erp/purchase-requisition/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
function handleDetail(item: PurchaseRequisition) {
|
||||
uni.navigateTo({ url: `/pages-erp/purchase-requisition/detail/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 审核 */
|
||||
function handleApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审核通过该请购单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePurchaseRequisitionStatus(id, 2)
|
||||
toast.success('审核成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 驳回 */
|
||||
function handleReject(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要驳回该请购单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePurchaseRequisitionStatus(id, 3)
|
||||
toast.success('驳回成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该请购单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deletePurchaseRequisition(id)
|
||||
toast.success('删除成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 刷新列表 */
|
||||
function refreshList() {
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
100
src/pages-erp/purchase-return/components/search-form.vue
Normal file
100
src/pages-erp/purchase-return/components/search-form.vue
Normal file
@@ -0,0 +1,100 @@
|
||||
<template>
|
||||
<!-- 搜索框入口 -->
|
||||
<view @click="visible = true">
|
||||
<wd-search :placeholder="placeholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="visible" position="top" @close="visible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">
|
||||
退货单编号
|
||||
</view>
|
||||
<wd-input
|
||||
v-model="formData.no"
|
||||
placeholder="请输入退货单编号"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">
|
||||
审核状态
|
||||
</view>
|
||||
<wd-radio-group v-model="formData.status" shape="button">
|
||||
<wd-radio :value="-1">
|
||||
全部
|
||||
</wd-radio>
|
||||
<wd-radio :value="10">
|
||||
待审核
|
||||
</wd-radio>
|
||||
<wd-radio :value="20">
|
||||
已审核
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">
|
||||
重置
|
||||
</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">
|
||||
搜索
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { getNavbarHeight } from '@/utils'
|
||||
|
||||
const emit = defineEmits<{
|
||||
search: [data: Record<string, any>]
|
||||
reset: []
|
||||
}>()
|
||||
|
||||
const visible = ref(false)
|
||||
const formData = reactive({
|
||||
no: undefined as string | undefined,
|
||||
status: -1,
|
||||
})
|
||||
|
||||
const statusMap: Record<number, string> = {
|
||||
10: '待审核',
|
||||
20: '已审核',
|
||||
}
|
||||
|
||||
/** 搜索条件 placeholder 拼接 */
|
||||
const placeholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (formData.no) {
|
||||
conditions.push(`编号:${formData.no}`)
|
||||
}
|
||||
if (formData.status !== -1) {
|
||||
conditions.push(`状态:${statusMap[formData.status] || formData.status}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索采购退货单'
|
||||
})
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
visible.value = false
|
||||
const params: Record<string, any> = {}
|
||||
if (formData.no) {
|
||||
params.no = formData.no
|
||||
}
|
||||
if (formData.status !== -1) {
|
||||
params.status = formData.status
|
||||
}
|
||||
emit('search', params)
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
formData.no = undefined
|
||||
formData.status = -1
|
||||
visible.value = false
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
309
src/pages-erp/purchase-return/detail/index.vue
Normal file
309
src/pages-erp/purchase-return/detail/index.vue
Normal file
@@ -0,0 +1,309 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采购退货详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view v-if="formData">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="退货单编号" :value="formData.no" />
|
||||
<wd-cell title="审核状态">
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getStatusClass(formData.status)"
|
||||
>
|
||||
{{ getStatusText(formData.status) }}
|
||||
</view>
|
||||
</wd-cell>
|
||||
<wd-cell title="供应商" :value="formData.supplierName || '-'" />
|
||||
<wd-cell title="退货时间" :value="formatDateTime(formData.returnTime)" />
|
||||
<wd-cell title="关联订单" :value="formData.orderNo || '-'" />
|
||||
<wd-cell title="创建人" :value="formData.creatorName || '-'" />
|
||||
<wd-cell title="创建时间" :value="formatDateTime(formData.createTime)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="合计数量" :value="String(formData.totalCount || 0)" />
|
||||
<wd-cell title="合计产品价格" :value="`¥${formData.totalProductPrice || 0}`" />
|
||||
<wd-cell title="合计税额" :value="`¥${formData.totalTaxPrice || 0}`" />
|
||||
<wd-cell title="优惠率" :value="`${formData.discountPercent || 0}%`" />
|
||||
<wd-cell title="优惠金额" :value="`¥${formData.discountPrice || 0}`" />
|
||||
<wd-cell title="其他费用" :value="`¥${formData.otherPrice || 0}`" />
|
||||
<wd-cell title="应退金额">
|
||||
<text class="text-[#e6a23c] font-semibold">¥{{ formData.totalPrice || 0 }}</text>
|
||||
</wd-cell>
|
||||
<wd-cell title="已退金额">
|
||||
<text class="text-[#52c41a] font-semibold">¥{{ formData.refundPrice || 0 }}</text>
|
||||
</wd-cell>
|
||||
<wd-cell title="未退金额">
|
||||
<text
|
||||
class="font-semibold"
|
||||
:class="(formData.totalPrice || 0) - (formData.refundPrice || 0) > 0 ? 'text-[#f5222d]' : 'text-[#999]'"
|
||||
>
|
||||
¥{{ (formData.totalPrice || 0) - (formData.refundPrice || 0) }}
|
||||
</text>
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 退货明细 -->
|
||||
<view class="mx-24rpx mt-24rpx">
|
||||
<view class="mb-16rpx text-32rpx text-[#333] font-semibold">
|
||||
退货明细({{ formData.items?.length || 0 }}项)
|
||||
</view>
|
||||
<view v-if="formData.items && formData.items.length > 0">
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="item.id || index"
|
||||
class="mb-16rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
>
|
||||
<!-- 产品头部 -->
|
||||
<view class="flex items-center justify-between bg-[#f8f8f8] px-24rpx py-16rpx">
|
||||
<view class="flex items-center">
|
||||
<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>
|
||||
<view class="p-24rpx">
|
||||
<!-- 产品规格 -->
|
||||
<view v-if="item.productSpec" class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<text class="mr-8rpx text-[#999]">规格:</text>
|
||||
<text>{{ item.productSpec }}</text>
|
||||
</view>
|
||||
<!-- 单价 / 数量 / 单位 -->
|
||||
<view class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">单价:</text>
|
||||
<text class="text-[#f5222d]">¥{{ item.productPrice || 0 }}</text>
|
||||
</view>
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">数量:</text>
|
||||
<text class="font-semibold">{{ item.count || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">单位:</text>
|
||||
<text>{{ item.productUnitName || '-' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 税率 / 税额 -->
|
||||
<view v-if="item.taxPercent" class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">税率:</text>
|
||||
<text>{{ item.taxPercent }}%</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">税额:</text>
|
||||
<text>¥{{ item.taxPrice || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 金额 / 库存 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">金额:</text>
|
||||
<text class="text-[#e6a23c]">¥{{ item.totalPrice || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">库存:</text>
|
||||
<text>{{ item.stockCount || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 备注 -->
|
||||
<view v-if="item.remark" class="text-24rpx text-[#999]">
|
||||
备注:{{ item.remark }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="py-60rpx text-center text-28rpx text-[#999]">
|
||||
暂无退货明细
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 备注 -->
|
||||
<wd-cell-group v-if="formData.remark" title="备注" border>
|
||||
<wd-cell :value="formData.remark" />
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<view class="yd-detail-footer-actions">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:update']) && formData?.status === 10"
|
||||
class="flex-1" type="warning" @click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:update-status']) && formData?.status === 10"
|
||||
class="flex-1" type="success" @click="handleAudit"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:update-status']) && formData?.status === 20"
|
||||
class="flex-1" type="warning" @click="handleReverseAudit"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:delete'])"
|
||||
class="flex-1" type="error" :loading="deleting" @click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PurchaseReturn } from '@/api/erp/purchase-return'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deletePurchaseReturn, getPurchaseReturn, updatePurchaseReturnStatus } from '@/api/erp/purchase-return'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
import { formatDateTime } from '@/utils/date'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const formData = ref<PurchaseReturn>()
|
||||
const deleting = ref(false)
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number) {
|
||||
if (status === 10) return '待审核'
|
||||
if (status === 20) return '已审核'
|
||||
return '未知'
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number) {
|
||||
if (status === 10) return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
if (status === 20) return 'bg-[#f6ffed] text-[#52c41a]'
|
||||
return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/purchase-return/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getPurchaseReturn(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑操作 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-return/form/index?id=${props.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 审批操作 */
|
||||
function handleAudit() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该退货单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await updatePurchaseReturnStatus(props.id, 20)
|
||||
toast.success('审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批操作 */
|
||||
function handleReverseAudit() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该退货单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await updatePurchaseReturnStatus(props.id, 10)
|
||||
toast.success('反审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除操作 */
|
||||
function handleDelete() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该采购退货单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
deleting.value = true
|
||||
try {
|
||||
await deletePurchaseReturn([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
609
src/pages-erp/purchase-return/form/index.vue
Normal file
609
src/pages-erp/purchase-return/form/index.vue
Normal file
@@ -0,0 +1,609 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view>
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="退货单号" title-width="180rpx" center>
|
||||
<wd-input
|
||||
v-model="formData.no"
|
||||
placeholder="保存时自动生成"
|
||||
disabled
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="退货时间" title-width="180rpx" prop="returnTime" center>
|
||||
<wd-datetime-picker
|
||||
v-model="formData.returnTime"
|
||||
type="date"
|
||||
label=""
|
||||
placeholder="请选择退货时间"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="关联订单" title-width="180rpx" center is-link @click="openOrderSelect">
|
||||
<text v-if="formData.orderNo" class="text-[#1890ff]">{{ formData.orderNo }}</text>
|
||||
<text v-else class="text-[#999]">点击选择采购订单</text>
|
||||
</wd-cell>
|
||||
<wd-cell title="供应商" title-width="180rpx" center>
|
||||
<text>{{ getSupplierName() || '-' }}</text>
|
||||
</wd-cell>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-cell-group title="费用信息" border>
|
||||
<wd-input
|
||||
v-model="formData.discountPercent"
|
||||
label="优惠率(%)"
|
||||
label-width="180rpx"
|
||||
type="number"
|
||||
placeholder="请输入优惠率"
|
||||
clearable
|
||||
/>
|
||||
<wd-cell title="退款优惠" title-width="180rpx" center>
|
||||
<text>¥{{ formData.discountPrice || 0 }}</text>
|
||||
</wd-cell>
|
||||
<wd-input
|
||||
v-model="formData.otherPrice"
|
||||
label="其他费用"
|
||||
label-width="180rpx"
|
||||
type="number"
|
||||
placeholder="请输入其他费用"
|
||||
clearable
|
||||
/>
|
||||
<wd-cell title="优惠后金额" title-width="180rpx" center>
|
||||
<text>¥{{ formData.totalPrice || 0 }}</text>
|
||||
</wd-cell>
|
||||
<wd-cell title="结算账户" title-width="180rpx" prop="accountId" center>
|
||||
<wd-picker
|
||||
v-model="formData.accountId"
|
||||
:columns="accountColumns"
|
||||
label=""
|
||||
placeholder="请选择结算账户"
|
||||
@confirm="onAccountConfirm"
|
||||
/>
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 退货明细 -->
|
||||
<view class="mx-24rpx mt-24rpx pb-180rpx">
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-32rpx text-[#333] font-semibold">
|
||||
退货明细({{ formData.items?.length || 0 }}项)
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mb-16rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
>
|
||||
<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>
|
||||
<view class="p-24rpx">
|
||||
<!-- 仓库选择 -->
|
||||
<view class="mb-16rpx">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">仓库</text>
|
||||
<wd-picker
|
||||
v-model="item.warehouseId"
|
||||
:columns="warehouseColumns"
|
||||
placeholder="请选择仓库"
|
||||
@confirm="(e: any) => onWarehouseConfirm(e, index)"
|
||||
/>
|
||||
</view>
|
||||
<!-- 自动填充的产品信息(只读) -->
|
||||
<view v-if="item.productId" class="mb-16rpx rounded-8rpx bg-[#f9f9f9] p-16rpx">
|
||||
<view class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">产品名称</text>
|
||||
<text class="text-[#333]">{{ item.productName || '-' }}</text>
|
||||
</view>
|
||||
<view v-if="item.productSpec" class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">规格</text>
|
||||
<text class="text-[#333]">{{ item.productSpec }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">单位</text>
|
||||
<text class="text-[#333]">{{ item.productUnitName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">条码</text>
|
||||
<text class="text-[#333]">{{ item.productBarCode || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">库存</text>
|
||||
<text class="text-[#333]">{{ item.stockCount || 0 }}</text>
|
||||
</view>
|
||||
<view v-if="item.inCount != null" class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">已入库</text>
|
||||
<text class="text-[#333]">{{ item.inCount }}</text>
|
||||
</view>
|
||||
<view v-if="item.returnCount != null" class="flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">已退货</text>
|
||||
<text class="text-[#333]">{{ item.returnCount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mb-16rpx flex gap-16rpx">
|
||||
<view class="flex-1">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">数量</text>
|
||||
<wd-input
|
||||
v-model="item.count"
|
||||
type="number"
|
||||
placeholder="数量"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="flex-1">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">单价(元)</text>
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
type="number"
|
||||
placeholder="单价"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mb-16rpx flex gap-16rpx">
|
||||
<view class="flex-1">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">税率(%)</text>
|
||||
<wd-input
|
||||
v-model="item.taxPercent"
|
||||
type="number"
|
||||
placeholder="税率"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="flex-1">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">金额</text>
|
||||
<text class="block pt-16rpx text-28rpx text-[#333]">{{ calcTotalPrice(item) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">备注</text>
|
||||
<wd-input
|
||||
v-model="item.remark"
|
||||
placeholder="请输入备注"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="!formData.items?.length" class="py-60rpx text-center text-28rpx text-[#999]">
|
||||
暂无产品,请先选择关联订单
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 采购订单选择弹窗(可退货订单) -->
|
||||
<wd-popup v-model="orderSelectVisible" position="right" custom-style="width: 100%; height: 100%;">
|
||||
<view class="yd-page-container">
|
||||
<wd-navbar
|
||||
title="选择采购订单"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="orderSelectVisible = false"
|
||||
/>
|
||||
<wd-search
|
||||
v-model="orderQueryParams.no"
|
||||
placeholder="搜索订单单号"
|
||||
@search="getOrderList"
|
||||
@clear="getOrderList"
|
||||
/>
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in orderList"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
:class="{ 'border-2 border-[#1890ff]': selectedOrderId === item.id }"
|
||||
@click="handleSelectOrder(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<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]">
|
||||
<text class="text-[#999]">供应商</text>
|
||||
<text>{{ item.supplierName || '-' }}</text>
|
||||
</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>
|
||||
</view>
|
||||
<view class="flex items-center justify-around mt-12rpx pt-12rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<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>
|
||||
<view class="text-center">
|
||||
<view class="text-28rpx text-[#f5222d] font-semibold">{{ item.returnCount || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999]">已退货</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="orderList.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无可退货订单" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="orderList.length > 0"
|
||||
:state="orderLoadMoreState"
|
||||
@reload="loadMoreOrders"
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button type="primary" block :disabled="!selectedOrderId" @click="confirmSelectOrder">
|
||||
确认选择
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { PurchaseReturn, PurchaseReturnItem } from '@/api/erp/purchase-return'
|
||||
import type { PurchaseOrder } from '@/api/erp/purchase-order'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createPurchaseReturn, getPurchaseReturn, updatePurchaseReturn } from '@/api/erp/purchase-return'
|
||||
import { getPurchaseOrder, getPurchaseOrderPage } from '@/api/erp/purchase-order'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
/** 账户简单信息 */
|
||||
interface AccountSimple {
|
||||
id: number
|
||||
name: string
|
||||
defaultStatus?: boolean
|
||||
}
|
||||
|
||||
/** 仓库简单信息 */
|
||||
interface WarehouseSimple {
|
||||
id: number
|
||||
name: string
|
||||
defaultStatus?: boolean
|
||||
}
|
||||
|
||||
/** 供应商简单信息 */
|
||||
interface SupplierSimple {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const toast = useToast()
|
||||
const getTitle = computed(() => props.id ? '编辑采购退货' : '新增采购退货')
|
||||
const formLoading = ref(false)
|
||||
const formData = ref<PurchaseReturn>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
supplierId: undefined,
|
||||
accountId: undefined,
|
||||
returnTime: undefined,
|
||||
orderId: undefined,
|
||||
orderNo: undefined,
|
||||
discountPercent: 0,
|
||||
discountPrice: 0,
|
||||
otherPrice: 0,
|
||||
totalPrice: 0,
|
||||
remark: '',
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
returnTime: [{ required: true, message: '退货时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
const supplierList = ref<SupplierSimple[]>([])
|
||||
const accountList = ref<AccountSimple[]>([])
|
||||
const warehouseList = ref<WarehouseSimple[]>([])
|
||||
const defaultWarehouse = ref<WarehouseSimple>()
|
||||
|
||||
// 采购订单选择相关(可退货订单)
|
||||
const orderSelectVisible = ref(false)
|
||||
const orderList = ref<PurchaseOrder[]>([])
|
||||
const orderLoadMoreState = ref<LoadMoreState>('loading')
|
||||
const orderQueryParams = ref({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
no: undefined as string | undefined,
|
||||
returnEnable: true, // 可退货订单
|
||||
})
|
||||
const orderTotal = ref(0)
|
||||
const selectedOrderId = ref<number>()
|
||||
|
||||
/** 账户下拉列 */
|
||||
const accountColumns = computed(() => [
|
||||
accountList.value.map(a => ({ value: a.id, label: a.name })),
|
||||
])
|
||||
|
||||
/** 仓库下拉列 */
|
||||
const warehouseColumns = computed(() => [
|
||||
warehouseList.value.map(w => ({ value: w.id, label: w.name })),
|
||||
])
|
||||
|
||||
/** 获取供应商名称 */
|
||||
function getSupplierName() {
|
||||
if (!formData.value.supplierId) return ''
|
||||
const supplier = supplierList.value.find(s => s.id === formData.value.supplierId)
|
||||
return supplier?.name || formData.value.supplierName || ''
|
||||
}
|
||||
|
||||
/** 账户选择回调 */
|
||||
function onAccountConfirm({ value }: any) {
|
||||
formData.value.accountId = value?.[0]
|
||||
}
|
||||
|
||||
/** 仓库选择回调 */
|
||||
function onWarehouseConfirm({ value }: any, index: number) {
|
||||
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])
|
||||
if (warehouse) {
|
||||
formData.value.items[index].warehouseName = warehouse.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算行项金额 */
|
||||
function calcTotalPrice(item: PurchaseReturnItem) {
|
||||
if (item.productPrice && item.count) {
|
||||
const productTotal = Number(item.productPrice) * Number(item.count)
|
||||
const taxPrice = item.taxPercent ? productTotal * Number(item.taxPercent) / 100 : 0
|
||||
return `¥${(productTotal + taxPrice).toFixed(2)}`
|
||||
}
|
||||
return '-'
|
||||
}
|
||||
|
||||
/** 监听表单数据变化,计算总价 */
|
||||
watch(
|
||||
() => formData.value,
|
||||
(val) => {
|
||||
if (!val || !val.items) return
|
||||
// 计算每个明细的金额
|
||||
val.items.forEach((item) => {
|
||||
if (item.productPrice && item.count) {
|
||||
item.totalProductPrice = Number(item.productPrice) * Number(item.count)
|
||||
item.taxPrice = item.taxPercent ? item.totalProductPrice * Number(item.taxPercent) / 100 : 0
|
||||
item.totalPrice = item.totalProductPrice + (item.taxPrice || 0)
|
||||
}
|
||||
})
|
||||
// 计算总价
|
||||
const totalPrice = val.items.reduce((prev, curr) => prev + (curr.totalPrice || 0), 0)
|
||||
const discountPrice = val.discountPercent ? totalPrice * Number(val.discountPercent) / 100 : 0
|
||||
formData.value.discountPrice = Math.round(discountPrice * 100) / 100
|
||||
formData.value.totalPrice = Math.round((totalPrice - discountPrice + Number(val.otherPrice || 0)) * 100) / 100
|
||||
},
|
||||
{ deep: true },
|
||||
)
|
||||
|
||||
/** 加载下拉列表数据 */
|
||||
async function loadDropdownData() {
|
||||
try {
|
||||
const { http } = await import('@/http/http')
|
||||
const [suppliers, accounts, warehouses] = await Promise.all([
|
||||
http.get<SupplierSimple[]>('/erp/supplier/simple-list'),
|
||||
http.get<AccountSimple[]>('/erp/account/simple-list'),
|
||||
http.get<WarehouseSimple[]>('/erp/warehouse/simple-list'),
|
||||
])
|
||||
supplierList.value = suppliers || []
|
||||
accountList.value = accounts || []
|
||||
warehouseList.value = warehouses || []
|
||||
// 设置默认账户
|
||||
const defaultAccount = accountList.value.find(a => a.defaultStatus)
|
||||
if (defaultAccount && !formData.value.accountId) {
|
||||
formData.value.accountId = defaultAccount.id
|
||||
}
|
||||
// 设置默认仓库
|
||||
defaultWarehouse.value = warehouseList.value.find(w => w.defaultStatus)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/purchase-return/index')
|
||||
}
|
||||
|
||||
/** 删除退货明细行 */
|
||||
function handleRemoveItem(index: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `确定要删除第 ${index + 1} 项产品吗?`,
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 打开订单选择弹窗 */
|
||||
function openOrderSelect() {
|
||||
orderSelectVisible.value = true
|
||||
orderQueryParams.value.pageNo = 1
|
||||
orderList.value = []
|
||||
selectedOrderId.value = formData.value.orderId
|
||||
getOrderList()
|
||||
}
|
||||
|
||||
/** 获取可退货订单列表 */
|
||||
async function getOrderList() {
|
||||
orderLoadMoreState.value = 'loading'
|
||||
try {
|
||||
const data = await getPurchaseOrderPage(orderQueryParams.value)
|
||||
if (orderQueryParams.value.pageNo === 1) {
|
||||
orderList.value = data.list
|
||||
} else {
|
||||
orderList.value = [...orderList.value, ...data.list]
|
||||
}
|
||||
orderTotal.value = data.total
|
||||
orderLoadMoreState.value = orderList.value.length >= orderTotal.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
orderLoadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 加载更多订单 */
|
||||
function loadMoreOrders() {
|
||||
if (orderLoadMoreState.value === 'finished') return
|
||||
orderQueryParams.value.pageNo++
|
||||
getOrderList()
|
||||
}
|
||||
|
||||
/** 选择订单 */
|
||||
function handleSelectOrder(item: PurchaseOrder) {
|
||||
selectedOrderId.value = item.id
|
||||
}
|
||||
|
||||
/** 确认选择订单 */
|
||||
async function confirmSelectOrder() {
|
||||
if (!selectedOrderId.value) return
|
||||
try {
|
||||
toast.loading('加载订单详情...')
|
||||
const orderDetail = await getPurchaseOrder(selectedOrderId.value)
|
||||
// 设置订单信息
|
||||
formData.value.orderId = orderDetail.id
|
||||
formData.value.orderNo = orderDetail.no
|
||||
formData.value.supplierId = orderDetail.supplierId
|
||||
formData.value.supplierName = orderDetail.supplierName
|
||||
formData.value.accountId = orderDetail.accountId
|
||||
formData.value.discountPercent = orderDetail.discountPercent
|
||||
formData.value.remark = orderDetail.remark
|
||||
// 设置退货明细(可退货数量 = 已入库 - 已退货)
|
||||
if (orderDetail.items) {
|
||||
formData.value.items = orderDetail.items
|
||||
.filter(item => ((item.inCount || 0) - (item.returnCount || 0)) > 0)
|
||||
.map(item => ({
|
||||
productId: item.productId,
|
||||
productName: item.productName,
|
||||
productUnitId: item.productUnitId,
|
||||
productUnitName: item.productUnitName,
|
||||
productPrice: item.productPrice,
|
||||
productSpec: item.productSpec,
|
||||
productBarCode: item.productBarCode,
|
||||
count: (item.inCount || 0) - (item.returnCount || 0),
|
||||
inCount: item.inCount,
|
||||
returnCount: item.returnCount,
|
||||
taxPercent: item.taxPercent,
|
||||
warehouseId: defaultWarehouse.value?.id,
|
||||
warehouseName: defaultWarehouse.value?.name,
|
||||
stockCount: item.stockCount,
|
||||
orderItemId: item.id,
|
||||
remark: item.remark,
|
||||
}))
|
||||
}
|
||||
orderSelectVisible.value = false
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getPurchaseReturn(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) {
|
||||
return
|
||||
}
|
||||
// 校验退货明细
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.warning('请至少添加一项退货产品')
|
||||
return
|
||||
}
|
||||
for (let i = 0; i < formData.value.items.length; i++) {
|
||||
const item = formData.value.items[i]
|
||||
if (!item.warehouseId) {
|
||||
toast.warning(`第 ${i + 1} 项产品请选择仓库`)
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.warning(`第 ${i + 1} 项产品数量不能为空`)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
if (props.id) {
|
||||
await updatePurchaseReturn(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createPurchaseReturn(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
await loadDropdownData()
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
366
src/pages-erp/purchase-return/index.vue
Normal file
366
src/pages-erp/purchase-return/index.vue
Normal file
@@ -0,0 +1,366 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采购退货"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<SearchForm @search="handleQuery" @reset="handleReset" />
|
||||
|
||||
<!-- 状态快速筛选 -->
|
||||
<view class="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
: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]"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 采购退货列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
@click="handleCardClick(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:单号 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.no }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getStatusClass(item.status)"
|
||||
>
|
||||
{{ getStatusText(item.status) }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 供应商 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">供应商</text>
|
||||
<text>{{ item.supplierName || '-' }}</text>
|
||||
</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>
|
||||
</view>
|
||||
<!-- 退货时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">退货时间</text>
|
||||
<text>{{ formatDate(item.returnTime) }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<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>
|
||||
<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>
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#52c41a] font-semibold">¥{{ item.refundPrice || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">已退</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view
|
||||
class="text-30rpx font-semibold"
|
||||
:class="(item.totalPrice || 0) - (item.refundPrice || 0) > 0 ? 'text-[#f5222d]' : 'text-[#999]'"
|
||||
>
|
||||
¥{{ (item.totalPrice || 0) - (item.refundPrice || 0) }}
|
||||
</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">未退</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:query'])"
|
||||
size="small" plain @click="handleDetail(item)"
|
||||
>
|
||||
详情
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:update']) && item.status === 10"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
修改
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleAudit(item.id!)"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:update-status']) && item.status === 20"
|
||||
size="small" type="warning" plain @click="handleReverseAudit(item.id!)"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:delete'])"
|
||||
size="small" type="error" plain @click="handleDelete(item.id!)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无采购退货数据" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 新增按钮 -->
|
||||
<wd-fab
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PurchaseReturn } from '@/api/erp/purchase-return'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deletePurchaseReturn, getPurchaseReturnPage, updatePurchaseReturnStatus } from '@/api/erp/purchase-return'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
import SearchForm from './components/search-form.vue'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<PurchaseReturn[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const activeStatus = ref<number | undefined>(undefined)
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
const statusTabs = [
|
||||
{ label: '全部', value: undefined },
|
||||
{ label: '待审核', value: 10 },
|
||||
{ label: '已审核', value: 20 },
|
||||
]
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(date?: string) {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleDateString('zh-CN')
|
||||
}
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number) {
|
||||
if (status === 10) return '待审核'
|
||||
if (status === 20) return '已审核'
|
||||
return '未知'
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number) {
|
||||
if (status === 10) return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
if (status === 20) return 'bg-[#f6ffed] text-[#52c41a]'
|
||||
return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询采购退货列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
const data = await getPurchaseReturnPage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 状态快速筛选 */
|
||||
function handleQuickFilter(status?: number) {
|
||||
activeStatus.value = status
|
||||
queryParams.value.status = status
|
||||
queryParams.value.pageNo = 1
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery(data?: Record<string, any>) {
|
||||
queryParams.value = {
|
||||
...data,
|
||||
status: activeStatus.value,
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function handleReset() {
|
||||
activeStatus.value = undefined
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') {
|
||||
return
|
||||
}
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 卡片点击 — 已审核打开详情,待审核打开编辑 */
|
||||
function handleCardClick(item: PurchaseReturn) {
|
||||
if (item.status === 20) {
|
||||
handleDetail(item)
|
||||
} else if (item.status === 10) {
|
||||
handleEdit(item)
|
||||
}
|
||||
}
|
||||
|
||||
/** 新增采购退货 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({
|
||||
url: '/pages-erp/purchase-return/form/index',
|
||||
})
|
||||
}
|
||||
|
||||
/** 查看详情 */
|
||||
function handleDetail(item: PurchaseReturn) {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-return/detail/index?id=${item.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: PurchaseReturn) {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-return/form/index?id=${item.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleAudit(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定审批该退货单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePurchaseReturnStatus(id, 20)
|
||||
toast.success('审批成功')
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseAudit(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定反审批该退货单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePurchaseReturnStatus(id, 10)
|
||||
toast.success('反审批成功')
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该采购退货单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deletePurchaseReturn([id])
|
||||
toast.success('删除成功')
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
238
src/pages-erp/stock-check/detail/index.vue
Normal file
238
src/pages-erp/stock-check/detail/index.vue
Normal file
@@ -0,0 +1,238 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="盘点单详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view class="pb-180rpx">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="盘点单号" :value="detail.no || '-'" />
|
||||
<wd-cell title="盘点时间" :value="formatDate(detail.checkTime)" />
|
||||
<wd-cell title="审核状态">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="detail.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ detail.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="备注" :value="detail.remark || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="盘点数量" :value="formatCount(detail.totalCount)" />
|
||||
<wd-cell title="盘点金额" :value="formatPrice(detail.totalPrice)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 盘点产品清单 -->
|
||||
<wd-cell-group title="盘点产品清单" border>
|
||||
<view v-if="!detail.items || detail.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品数据
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in detail.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '-' }}
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">仓库</text>
|
||||
<text class="text-[#666]">{{ item.warehouseName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">账面数量</text>
|
||||
<text class="text-[#666]">{{ formatCount(item.stockCount) }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">实际数量</text>
|
||||
<text class="text-[#666]">{{ formatCount(item.actualCount) }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">盈亏数量</text>
|
||||
<text
|
||||
class="font-semibold"
|
||||
:class="(item.count || 0) >= 0 ? 'text-[#52c41a]' : 'text-[#f5222d]'"
|
||||
>
|
||||
{{ (item.count || 0) >= 0 ? '+' : '' }}{{ formatCount(item.count) }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-check:update']) && detail.status === 10"
|
||||
type="primary"
|
||||
@click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-check:update-status']) && detail.status === 10"
|
||||
type="success"
|
||||
@click="handleApprove"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-check:update-status']) && detail.status === 20"
|
||||
type="warning"
|
||||
@click="handleReverseApprove"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-check:delete']) && detail.status === 10"
|
||||
type="error"
|
||||
@click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockCheck } from '@/api/erp/stock-check'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockCheck, getStockCheck, updateStockCheckStatus } from '@/api/erp/stock-check'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const detail = ref<StockCheck>({})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/stock-check/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
detail.value = await getStockCheck(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-check/form/index?id=${props.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该盘点单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockCheckStatus(props.id, 20)
|
||||
toast.success('审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该盘点单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockCheckStatus(props.id, 10)
|
||||
toast.success('反审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该盘点单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockCheck([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
402
src/pages-erp/stock-check/form/index.vue
Normal file
402
src/pages-erp/stock-check/form/index.vue
Normal file
@@ -0,0 +1,402 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="盘点单号" :value="formData.no || '保存时自动生成'" />
|
||||
<wd-cell
|
||||
title="盘点时间"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="formData.checkTime ? formatDate(formData.checkTime) : '请选择'"
|
||||
@click="datePickerVisible = true"
|
||||
/>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 盘点产品清单 -->
|
||||
<wd-cell-group title="盘点产品清单" border>
|
||||
<view v-if="formData.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品,请点击下方按钮添加
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '请选择产品' }}
|
||||
</view>
|
||||
<wd-icon name="delete" size="40rpx" color="#f56c6c" @click="removeItem(index)" />
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="仓库"
|
||||
title-width="140rpx"
|
||||
is-link
|
||||
:value="item.warehouseName || '请选择'"
|
||||
@click="openWarehousePicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="产品"
|
||||
title-width="140rpx"
|
||||
is-link
|
||||
:value="item.productName || '请选择'"
|
||||
@click="openProductPicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.stockCount"
|
||||
label="账面数量"
|
||||
label-width="140rpx"
|
||||
type="number"
|
||||
placeholder="请输入账面数量"
|
||||
@change="calcItemDiff(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.actualCount"
|
||||
label="实际数量"
|
||||
label-width="140rpx"
|
||||
type="number"
|
||||
placeholder="请输入实际数量"
|
||||
@change="calcItemDiff(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">盈亏数量</text>
|
||||
<text
|
||||
class="font-semibold"
|
||||
:class="(item.count || 0) >= 0 ? 'text-[#52c41a]' : 'text-[#f5222d]'"
|
||||
>
|
||||
{{ (item.count || 0) >= 0 ? '+' : '' }}{{ formatCount(item.count) }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
label="单价"
|
||||
label-width="140rpx"
|
||||
type="digit"
|
||||
placeholder="请输入单价"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="px-24rpx pb-24rpx">
|
||||
<wd-button type="primary" plain block @click="addItem">
|
||||
<wd-icon name="add" class="mr-8rpx" />
|
||||
添加产品
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 合计信息 -->
|
||||
<wd-cell-group title="合计信息" border>
|
||||
<wd-cell title="盘点数量" :value="formatCount(totalCount)" />
|
||||
<wd-cell title="盘点金额" :value="formatPrice(totalPrice)" />
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 日期选择器 -->
|
||||
<wd-datetime-picker
|
||||
v-model="datePickerVisible"
|
||||
type="date"
|
||||
:value="formData.checkTime"
|
||||
@confirm="onDateConfirm"
|
||||
/>
|
||||
|
||||
<!-- 仓库选择器 -->
|
||||
<wd-picker
|
||||
v-model="warehousePickerVisible"
|
||||
:columns="warehouseColumns"
|
||||
@confirm="onWarehouseConfirm"
|
||||
/>
|
||||
|
||||
<!-- 产品选择器 -->
|
||||
<wd-picker
|
||||
v-model="productPickerVisible"
|
||||
:columns="productColumns"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { StockCheck, StockCheckItem } from '@/api/erp/stock-check'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createStockCheck, getStockCheck, updateStockCheck } from '@/api/erp/stock-check'
|
||||
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const toast = useToast()
|
||||
const getTitle = computed(() => props.id ? '编辑盘点单' : '新增盘点单')
|
||||
const formLoading = ref(false)
|
||||
const formData = ref<StockCheck>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
checkTime: undefined,
|
||||
remark: undefined,
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
checkTime: [{ required: true, message: '盘点时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 仓库列表
|
||||
const warehouseList = ref<{ id: number, name: string }[]>([])
|
||||
const warehousePickerVisible = ref(false)
|
||||
const warehouseColumns = computed(() => [
|
||||
warehouseList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 产品列表
|
||||
const productList = ref<{ id: number, name: string, unitName?: string }[]>([])
|
||||
const productPickerVisible = ref(false)
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 日期选择器
|
||||
const datePickerVisible = ref(false)
|
||||
|
||||
// 当前编辑的产品项索引
|
||||
const currentItemIndex = ref(-1)
|
||||
|
||||
/** 合计数量 */
|
||||
const totalCount = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + Math.abs(Number(item.count) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计金额 */
|
||||
const totalPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + Math.abs(Number(item.totalPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
if (typeof dateStr === 'number') {
|
||||
const d = new Date(dateStr)
|
||||
const pad = (n: number) => n.toString().padStart(2, '0')
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
|
||||
}
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/stock-check/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getStockCheck(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 日期确认 */
|
||||
function onDateConfirm({ value }: any) {
|
||||
formData.value.checkTime = value
|
||||
datePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开仓库选择器 */
|
||||
function openWarehousePicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
warehousePickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 仓库确认 */
|
||||
function onWarehouseConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.warehouseId = value?.[0]
|
||||
const warehouse = warehouseList.value.find(w => w.id === item.warehouseId)
|
||||
item.warehouseName = warehouse?.name
|
||||
}
|
||||
warehousePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开产品选择器 */
|
||||
function openProductPicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
productPickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 产品确认 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.productId = value?.[0]
|
||||
const product = productList.value.find(p => p.id === item.productId)
|
||||
item.productName = product?.name
|
||||
item.productUnitName = product?.unitName
|
||||
}
|
||||
productPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 添加产品项 */
|
||||
function addItem() {
|
||||
if (!formData.value.items) {
|
||||
formData.value.items = []
|
||||
}
|
||||
formData.value.items.push({
|
||||
warehouseId: undefined,
|
||||
warehouseName: undefined,
|
||||
productId: undefined,
|
||||
productName: undefined,
|
||||
productUnitName: undefined,
|
||||
stockCount: undefined,
|
||||
actualCount: undefined,
|
||||
count: 0,
|
||||
productPrice: undefined,
|
||||
totalPrice: 0,
|
||||
})
|
||||
}
|
||||
|
||||
/** 移除产品项 */
|
||||
function removeItem(index: number) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 计算盈亏数量 */
|
||||
function calcItemDiff(item: StockCheckItem) {
|
||||
const stockCount = Number(item.stockCount) || 0
|
||||
const actualCount = Number(item.actualCount) || 0
|
||||
item.count = actualCount - stockCount
|
||||
calcItemTotal(item)
|
||||
}
|
||||
|
||||
/** 计算产品项金额 */
|
||||
function calcItemTotal(item: StockCheckItem) {
|
||||
const count = Math.abs(Number(item.count) || 0)
|
||||
const price = Number(item.productPrice) || 0
|
||||
item.totalPrice = count * price
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
// 校验产品清单
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.error('请添加盘点产品')
|
||||
return
|
||||
}
|
||||
|
||||
for (const item of formData.value.items) {
|
||||
if (!item.warehouseId) {
|
||||
toast.error('请选择仓库')
|
||||
return
|
||||
}
|
||||
if (!item.productId) {
|
||||
toast.error('请选择产品')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
// 设置合计
|
||||
formData.value.totalCount = totalCount.value
|
||||
formData.value.totalPrice = totalPrice.value
|
||||
|
||||
if (props.id) {
|
||||
await updateStockCheck(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createStockCheck(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await getWarehouseSimpleList()
|
||||
// 加载详情
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
383
src/pages-erp/stock-check/index.vue
Normal file
383
src/pages-erp/stock-check/index.vue
Normal file
@@ -0,0 +1,383 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="库存盘点"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<view @click="searchVisible = true">
|
||||
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 快捷筛选标签 -->
|
||||
<view class="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
:class="queryParams.status === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'"
|
||||
@click="onTabChange(tab.value)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<view
|
||||
v-if="queryParams.status === tab.value"
|
||||
class="absolute bottom-0 left-1/4 w-1/2 h-4rpx rounded-2rpx bg-[#1890ff]"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 盘点单列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
@click="handleDetail(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:单号 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.no || '-' }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="item.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ item.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</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>
|
||||
</view>
|
||||
<!-- 盘点时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">盘点时间</text>
|
||||
<text>{{ formatDate(item.checkTime) }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#333] font-semibold">{{ formatCount(item.totalCount) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">盘点数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">盘点金额</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-check:update']) && item.status === 10"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-check:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleApprove(item.id!)"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-check:update-status']) && item.status === 20"
|
||||
size="small" type="warning" plain @click="handleReverseApprove(item.id!)"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-check:delete']) && item.status === 10"
|
||||
size="small" type="error" plain @click="handleDelete(item.id!)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无盘点单数据" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 新增按钮 -->
|
||||
<wd-fab
|
||||
v-if="hasAccessByCodes(['erp:stock-check:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">盘点单号</view>
|
||||
<wd-input v-model="searchForm.no" placeholder="请输入盘点单号" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">审核状态</view>
|
||||
<view class="yd-search-form-radio-group">
|
||||
<view
|
||||
v-for="opt in statusOptions"
|
||||
:key="opt.value"
|
||||
class="yd-search-form-radio"
|
||||
:class="{ 'yd-search-form-radio--active': searchForm.status === opt.value }"
|
||||
@click="searchForm.status = opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">重置</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">搜索</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockCheck } from '@/api/erp/stock-check'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockCheck, getStockCheckPage, updateStockCheckStatus } from '@/api/erp/stock-check'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<StockCheck[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
status: undefined,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
no: undefined as string | undefined,
|
||||
status: undefined as number | undefined,
|
||||
})
|
||||
|
||||
/** 状态标签 */
|
||||
const statusTabs = [
|
||||
{ value: undefined, label: '全部' },
|
||||
{ value: 10, label: '未审核' },
|
||||
{ value: 20, label: '已审核' },
|
||||
]
|
||||
|
||||
/** 状态选项 */
|
||||
const statusOptions = [
|
||||
{ value: undefined, label: '全部' },
|
||||
{ value: 10, label: '未审核' },
|
||||
{ value: 20, label: '已审核' },
|
||||
]
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.no) conditions.push(`单号:${searchForm.no}`)
|
||||
if (searchForm.status !== undefined) {
|
||||
const statusLabel = statusOptions.find(o => o.value === searchForm.status)?.label
|
||||
if (statusLabel && statusLabel !== '全部') conditions.push(`状态:${statusLabel}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索盘点单'
|
||||
})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 切换状态标签 */
|
||||
function onTabChange(status: number | undefined) {
|
||||
queryParams.value.status = status
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 查询盘点单列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
if (searchForm.no) params.no = searchForm.no
|
||||
const data = await getStockCheckPage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
searchVisible.value = false
|
||||
queryParams.value = {
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
status: searchForm.status,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.no = undefined
|
||||
searchForm.status = undefined
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10, status: undefined }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 新增盘点单 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/stock-check/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: StockCheck) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-check/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
function handleDetail(item: StockCheck) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-check/detail/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该盘点单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockCheckStatus(id, 20)
|
||||
toast.success('审批成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该盘点单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockCheckStatus(id, 10)
|
||||
toast.success('反审批成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该盘点单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockCheck([id])
|
||||
toast.success('删除成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 刷新列表 */
|
||||
function refreshList() {
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
226
src/pages-erp/stock-gain/detail/index.vue
Normal file
226
src/pages-erp/stock-gain/detail/index.vue
Normal file
@@ -0,0 +1,226 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="报溢单详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view class="pb-180rpx">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="报溢单号" :value="detail.no || '-'" />
|
||||
<wd-cell title="报溢时间" :value="formatDate(detail.gainTime)" />
|
||||
<wd-cell title="报溢原因" :value="detail.reason || '-'" />
|
||||
<wd-cell title="审核状态">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="detail.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ detail.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="备注" :value="detail.remark || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(detail.totalCount)" />
|
||||
<wd-cell title="合计金额" :value="formatPrice(detail.totalPrice)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 报溢产品清单 -->
|
||||
<wd-cell-group title="报溢产品清单" border>
|
||||
<view v-if="!detail.items || detail.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品数据
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in detail.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '-' }}
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">仓库</text>
|
||||
<text class="text-[#666]">{{ item.warehouseName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">数量</text>
|
||||
<text class="text-[#52c41a] font-semibold">+{{ formatCount(item.count) }}</text>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:update']) && detail.status === 10"
|
||||
type="primary"
|
||||
@click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:update-status']) && detail.status === 10"
|
||||
type="success"
|
||||
@click="handleApprove"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:update-status']) && detail.status === 20"
|
||||
type="warning"
|
||||
@click="handleReverseApprove"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:delete']) && detail.status === 10"
|
||||
type="error"
|
||||
@click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockGain } from '@/api/erp/stock-gain'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockGain, getStockGain, updateStockGainStatus } from '@/api/erp/stock-gain'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const detail = ref<StockGain>({})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/stock-gain/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
detail.value = await getStockGain(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-gain/form/index?id=${props.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该报溢单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockGainStatus(props.id, 20)
|
||||
toast.success('审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该报溢单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockGainStatus(props.id, 10)
|
||||
toast.success('反审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该报溢单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockGain([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
385
src/pages-erp/stock-gain/form/index.vue
Normal file
385
src/pages-erp/stock-gain/form/index.vue
Normal file
@@ -0,0 +1,385 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="报溢单号" :value="formData.no || '保存时自动生成'" />
|
||||
<wd-cell
|
||||
title="报溢时间"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="formData.gainTime ? formatDate(formData.gainTime) : '请选择'"
|
||||
@click="datePickerVisible = true"
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.reason"
|
||||
label="报溢原因"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入报溢原因"
|
||||
clearable
|
||||
/>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 报溢产品清单 -->
|
||||
<wd-cell-group title="报溢产品清单" border>
|
||||
<view v-if="formData.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品,请点击下方按钮添加
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '请选择产品' }}
|
||||
</view>
|
||||
<wd-icon name="delete" size="40rpx" color="#f56c6c" @click="removeItem(index)" />
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="仓库"
|
||||
title-width="120rpx"
|
||||
is-link
|
||||
:value="item.warehouseName || '请选择'"
|
||||
@click="openWarehousePicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="产品"
|
||||
title-width="120rpx"
|
||||
is-link
|
||||
:value="item.productName || '请选择'"
|
||||
@click="openProductPicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.count"
|
||||
label="数量"
|
||||
label-width="120rpx"
|
||||
type="number"
|
||||
placeholder="请输入数量"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
label="单价"
|
||||
label-width="120rpx"
|
||||
type="digit"
|
||||
placeholder="请输入单价"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="px-24rpx pb-24rpx">
|
||||
<wd-button type="primary" plain block @click="addItem">
|
||||
<wd-icon name="add" class="mr-8rpx" />
|
||||
添加产品
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 合计信息 -->
|
||||
<wd-cell-group title="合计信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(totalCount)" />
|
||||
<wd-cell title="合计金额" :value="formatPrice(totalPrice)" />
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 日期选择器 -->
|
||||
<wd-datetime-picker
|
||||
v-model="datePickerVisible"
|
||||
type="date"
|
||||
:value="formData.gainTime"
|
||||
@confirm="onDateConfirm"
|
||||
/>
|
||||
|
||||
<!-- 仓库选择器 -->
|
||||
<wd-picker
|
||||
v-model="warehousePickerVisible"
|
||||
:columns="warehouseColumns"
|
||||
@confirm="onWarehouseConfirm"
|
||||
/>
|
||||
|
||||
<!-- 产品选择器 -->
|
||||
<wd-picker
|
||||
v-model="productPickerVisible"
|
||||
:columns="productColumns"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { StockGain, StockGainItem } from '@/api/erp/stock-gain'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createStockGain, getStockGain, updateStockGain } from '@/api/erp/stock-gain'
|
||||
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const toast = useToast()
|
||||
const getTitle = computed(() => props.id ? '编辑报溢单' : '新增报溢单')
|
||||
const formLoading = ref(false)
|
||||
const formData = ref<StockGain>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
gainTime: undefined,
|
||||
reason: undefined,
|
||||
remark: undefined,
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
gainTime: [{ required: true, message: '报溢时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 仓库列表
|
||||
const warehouseList = ref<{ id: number, name: string }[]>([])
|
||||
const warehousePickerVisible = ref(false)
|
||||
const warehouseColumns = computed(() => [
|
||||
warehouseList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 产品列表
|
||||
const productList = ref<{ id: number, name: string, unitName?: string }[]>([])
|
||||
const productPickerVisible = ref(false)
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 日期选择器
|
||||
const datePickerVisible = ref(false)
|
||||
|
||||
// 当前编辑的产品项索引
|
||||
const currentItemIndex = ref(-1)
|
||||
|
||||
/** 合计数量 */
|
||||
const totalCount = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.count) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计金额 */
|
||||
const totalPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.totalPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
if (typeof dateStr === 'number') {
|
||||
const d = new Date(dateStr)
|
||||
const pad = (n: number) => n.toString().padStart(2, '0')
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
|
||||
}
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/stock-gain/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getStockGain(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 日期确认 */
|
||||
function onDateConfirm({ value }: any) {
|
||||
formData.value.gainTime = value
|
||||
datePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开仓库选择器 */
|
||||
function openWarehousePicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
warehousePickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 仓库确认 */
|
||||
function onWarehouseConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.warehouseId = value?.[0]
|
||||
const warehouse = warehouseList.value.find(w => w.id === item.warehouseId)
|
||||
item.warehouseName = warehouse?.name
|
||||
}
|
||||
warehousePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开产品选择器 */
|
||||
function openProductPicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
productPickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 产品确认 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.productId = value?.[0]
|
||||
const product = productList.value.find(p => p.id === item.productId)
|
||||
item.productName = product?.name
|
||||
item.productUnitName = product?.unitName
|
||||
}
|
||||
productPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 添加产品项 */
|
||||
function addItem() {
|
||||
if (!formData.value.items) {
|
||||
formData.value.items = []
|
||||
}
|
||||
formData.value.items.push({
|
||||
warehouseId: undefined,
|
||||
warehouseName: undefined,
|
||||
productId: undefined,
|
||||
productName: undefined,
|
||||
productUnitName: undefined,
|
||||
count: undefined,
|
||||
productPrice: undefined,
|
||||
totalPrice: 0,
|
||||
})
|
||||
}
|
||||
|
||||
/** 移除产品项 */
|
||||
function removeItem(index: number) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 计算产品项金额 */
|
||||
function calcItemTotal(item: StockGainItem) {
|
||||
const count = Number(item.count) || 0
|
||||
const price = Number(item.productPrice) || 0
|
||||
item.totalPrice = count * price
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
// 校验产品清单
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.error('请添加报溢产品')
|
||||
return
|
||||
}
|
||||
|
||||
for (const item of formData.value.items) {
|
||||
if (!item.warehouseId) {
|
||||
toast.error('请选择仓库')
|
||||
return
|
||||
}
|
||||
if (!item.productId) {
|
||||
toast.error('请选择产品')
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.error('请输入有效的数量')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
// 设置合计
|
||||
formData.value.totalCount = totalCount.value
|
||||
formData.value.totalPrice = totalPrice.value
|
||||
|
||||
if (props.id) {
|
||||
await updateStockGain(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createStockGain(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await getWarehouseSimpleList()
|
||||
// 加载详情
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
388
src/pages-erp/stock-gain/index.vue
Normal file
388
src/pages-erp/stock-gain/index.vue
Normal file
@@ -0,0 +1,388 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="库存报溢"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<view @click="searchVisible = true">
|
||||
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 快捷筛选标签 -->
|
||||
<view class="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
:class="queryParams.status === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'"
|
||||
@click="onTabChange(tab.value)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<view
|
||||
v-if="queryParams.status === tab.value"
|
||||
class="absolute bottom-0 left-1/4 w-1/2 h-4rpx rounded-2rpx bg-[#1890ff]"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 报溢单列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
@click="handleDetail(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:单号 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.no || '-' }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="item.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ item.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</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>
|
||||
</view>
|
||||
<!-- 报溢时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">报溢时间</text>
|
||||
<text>{{ formatDate(item.gainTime) }}</text>
|
||||
</view>
|
||||
<!-- 报溢原因 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">报溢原因</text>
|
||||
<text>{{ item.reason || '-' }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#52c41a] font-semibold">{{ formatCount(item.totalCount) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">金额</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:update']) && item.status === 10"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleApprove(item.id!)"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:update-status']) && item.status === 20"
|
||||
size="small" type="warning" plain @click="handleReverseApprove(item.id!)"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:delete']) && item.status === 10"
|
||||
size="small" type="error" plain @click="handleDelete(item.id!)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无报溢单数据" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 新增按钮 -->
|
||||
<wd-fab
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">报溢单号</view>
|
||||
<wd-input v-model="searchForm.no" placeholder="请输入报溢单号" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">审核状态</view>
|
||||
<view class="yd-search-form-radio-group">
|
||||
<view
|
||||
v-for="opt in statusOptions"
|
||||
:key="opt.value"
|
||||
class="yd-search-form-radio"
|
||||
:class="{ 'yd-search-form-radio--active': searchForm.status === opt.value }"
|
||||
@click="searchForm.status = opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">重置</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">搜索</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockGain } from '@/api/erp/stock-gain'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockGain, getStockGainPage, updateStockGainStatus } from '@/api/erp/stock-gain'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<StockGain[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
status: undefined,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
no: undefined as string | undefined,
|
||||
status: undefined as number | undefined,
|
||||
})
|
||||
|
||||
/** 状态标签 */
|
||||
const statusTabs = [
|
||||
{ value: undefined, label: '全部' },
|
||||
{ value: 10, label: '未审核' },
|
||||
{ value: 20, label: '已审核' },
|
||||
]
|
||||
|
||||
/** 状态选项 */
|
||||
const statusOptions = [
|
||||
{ value: undefined, label: '全部' },
|
||||
{ value: 10, label: '未审核' },
|
||||
{ value: 20, label: '已审核' },
|
||||
]
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.no) conditions.push(`单号:${searchForm.no}`)
|
||||
if (searchForm.status !== undefined) {
|
||||
const statusLabel = statusOptions.find(o => o.value === searchForm.status)?.label
|
||||
if (statusLabel && statusLabel !== '全部') conditions.push(`状态:${statusLabel}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索报溢单'
|
||||
})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 切换状态标签 */
|
||||
function onTabChange(status: number | undefined) {
|
||||
queryParams.value.status = status
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 查询报溢单列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
if (searchForm.no) params.no = searchForm.no
|
||||
const data = await getStockGainPage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
searchVisible.value = false
|
||||
queryParams.value = {
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
status: searchForm.status,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.no = undefined
|
||||
searchForm.status = undefined
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10, status: undefined }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 新增报溢单 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/stock-gain/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: StockGain) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-gain/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
function handleDetail(item: StockGain) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-gain/detail/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该报溢单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockGainStatus(id, 20)
|
||||
toast.success('审批成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该报溢单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockGainStatus(id, 10)
|
||||
toast.success('反审批成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该报溢单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockGain([id])
|
||||
toast.success('删除成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 刷新列表 */
|
||||
function refreshList() {
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
238
src/pages-erp/stock-in/detail/index.vue
Normal file
238
src/pages-erp/stock-in/detail/index.vue
Normal file
@@ -0,0 +1,238 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="入库单详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view class="pb-180rpx">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="入库单号" :value="detail.no || '-'" />
|
||||
<wd-cell title="入库时间" :value="formatDate(detail.inTime)" />
|
||||
<wd-cell title="供应商" :value="detail.supplierName || '-'" />
|
||||
<wd-cell title="审核状态">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="detail.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ detail.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="备注" :value="detail.remark || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(detail.totalCount)" />
|
||||
<wd-cell title="合计金额" :value="formatPrice(detail.totalPrice)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 入库产品清单 -->
|
||||
<wd-cell-group title="入库产品清单" border>
|
||||
<view v-if="!detail.items || detail.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品数据
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in detail.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '-' }}
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">仓库</text>
|
||||
<text class="text-[#666]">{{ item.warehouseName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">单位</text>
|
||||
<text class="text-[#666]">{{ item.productUnitName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">数量</text>
|
||||
<text class="text-[#666]">{{ formatCount(item.count) }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">单价</text>
|
||||
<text class="text-[#666]">{{ formatPrice(item.productPrice) }}</text>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
<view v-if="item.remark" class="mt-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">备注</text>
|
||||
<text class="text-[#666]">{{ item.remark }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-in:update']) && detail.status !== 20"
|
||||
type="primary"
|
||||
@click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-in:update-status']) && detail.status === 10"
|
||||
type="success"
|
||||
@click="handleApprove"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-in:update-status']) && detail.status === 20"
|
||||
type="warning"
|
||||
@click="handleReverseApprove"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-in:delete']) && detail.status !== 20"
|
||||
type="error"
|
||||
@click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockIn } from '@/api/erp/stock-in'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockIn, getStockIn, updateStockInStatus } from '@/api/erp/stock-in'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const detail = ref<StockIn>({})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/stock-in/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
detail.value = await getStockIn(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-in/form/index?id=${props.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockInStatus(props.id, 20)
|
||||
toast.success('审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockInStatus(props.id, 10)
|
||||
toast.success('反审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockIn([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
424
src/pages-erp/stock-in/form/index.vue
Normal file
424
src/pages-erp/stock-in/form/index.vue
Normal file
@@ -0,0 +1,424 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="入库单号" :value="formData.no || '保存时自动生成'" />
|
||||
<wd-cell
|
||||
title="入库时间"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="formData.inTime ? formatDate(formData.inTime) : '请选择'"
|
||||
@click="datePickerVisible = true"
|
||||
/>
|
||||
<wd-cell
|
||||
title="供应商"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="getSupplierName()"
|
||||
@click="supplierPickerVisible = true"
|
||||
/>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 入库产品清单 -->
|
||||
<wd-cell-group title="入库产品清单" border>
|
||||
<view v-if="formData.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品,请点击下方按钮添加
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '请选择产品' }}
|
||||
</view>
|
||||
<wd-icon name="delete" size="40rpx" color="#f56c6c" @click="removeItem(index)" />
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="仓库"
|
||||
title-width="120rpx"
|
||||
is-link
|
||||
:value="item.warehouseName || '请选择'"
|
||||
@click="openWarehousePicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="产品"
|
||||
title-width="120rpx"
|
||||
is-link
|
||||
:value="item.productName || '请选择'"
|
||||
@click="openProductPicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.count"
|
||||
label="数量"
|
||||
label-width="120rpx"
|
||||
type="number"
|
||||
placeholder="请输入数量"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
label="单价"
|
||||
label-width="120rpx"
|
||||
type="digit"
|
||||
placeholder="请输入单价"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
<view class="mt-12rpx">
|
||||
<wd-input
|
||||
v-model="item.remark"
|
||||
label="备注"
|
||||
label-width="120rpx"
|
||||
placeholder="请输入备注"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="px-24rpx pb-24rpx">
|
||||
<wd-button type="primary" plain block @click="addItem">
|
||||
<wd-icon name="add" class="mr-8rpx" />
|
||||
添加产品
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 合计信息 -->
|
||||
<wd-cell-group title="合计信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(totalCount)" />
|
||||
<wd-cell title="合计金额" :value="formatPrice(totalPrice)" />
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 日期选择器 -->
|
||||
<wd-datetime-picker
|
||||
v-model="datePickerVisible"
|
||||
type="date"
|
||||
:value="formData.inTime"
|
||||
@confirm="onDateConfirm"
|
||||
/>
|
||||
|
||||
<!-- 供应商选择器 -->
|
||||
<wd-picker
|
||||
v-model="supplierPickerVisible"
|
||||
:columns="supplierColumns"
|
||||
@confirm="onSupplierConfirm"
|
||||
/>
|
||||
|
||||
<!-- 仓库选择器 -->
|
||||
<wd-picker
|
||||
v-model="warehousePickerVisible"
|
||||
:columns="warehouseColumns"
|
||||
@confirm="onWarehouseConfirm"
|
||||
/>
|
||||
|
||||
<!-- 产品选择器 -->
|
||||
<wd-picker
|
||||
v-model="productPickerVisible"
|
||||
:columns="productColumns"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { StockIn, StockInItem } from '@/api/erp/stock-in'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createStockIn, getStockIn, updateStockIn } from '@/api/erp/stock-in'
|
||||
import { getSupplierSimpleList } from '@/api/erp/supplier'
|
||||
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const toast = useToast()
|
||||
const getTitle = computed(() => props.id ? '编辑入库单' : '新增入库单')
|
||||
const formLoading = ref(false)
|
||||
const formData = ref<StockIn>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
supplierId: undefined,
|
||||
inTime: undefined,
|
||||
remark: undefined,
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
inTime: [{ required: true, message: '入库时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 供应商列表
|
||||
const supplierList = ref<{ id: number, name: string }[]>([])
|
||||
const supplierPickerVisible = ref(false)
|
||||
const supplierColumns = computed(() => [
|
||||
supplierList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 仓库列表
|
||||
const warehouseList = ref<{ id: number, name: string }[]>([])
|
||||
const warehousePickerVisible = ref(false)
|
||||
const warehouseColumns = computed(() => [
|
||||
warehouseList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 产品列表(简化,实际可能需要从产品API获取)
|
||||
const productList = ref<{ id: number, name: string, unitName?: string }[]>([])
|
||||
const productPickerVisible = ref(false)
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 日期选择器
|
||||
const datePickerVisible = ref(false)
|
||||
|
||||
// 当前编辑的产品项索引
|
||||
const currentItemIndex = ref(-1)
|
||||
|
||||
/** 合计数量 */
|
||||
const totalCount = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.count) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计金额 */
|
||||
const totalPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.totalPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 获取供应商名称 */
|
||||
function getSupplierName() {
|
||||
if (!formData.value.supplierId) return '请选择'
|
||||
const supplier = supplierList.value.find(s => s.id === formData.value.supplierId)
|
||||
return supplier?.name || '请选择'
|
||||
}
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
if (typeof dateStr === 'number') {
|
||||
const d = new Date(dateStr)
|
||||
const pad = (n: number) => n.toString().padStart(2, '0')
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
|
||||
}
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/stock-in/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getStockIn(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 日期确认 */
|
||||
function onDateConfirm({ value }: any) {
|
||||
formData.value.inTime = value
|
||||
datePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 供应商确认 */
|
||||
function onSupplierConfirm({ value }: any) {
|
||||
formData.value.supplierId = value?.[0]
|
||||
supplierPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开仓库选择器 */
|
||||
function openWarehousePicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
warehousePickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 仓库确认 */
|
||||
function onWarehouseConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.warehouseId = value?.[0]
|
||||
const warehouse = warehouseList.value.find(w => w.id === item.warehouseId)
|
||||
item.warehouseName = warehouse?.name
|
||||
}
|
||||
warehousePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开产品选择器 */
|
||||
function openProductPicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
productPickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 产品确认 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.productId = value?.[0]
|
||||
const product = productList.value.find(p => p.id === item.productId)
|
||||
item.productName = product?.name
|
||||
item.productUnitName = product?.unitName
|
||||
}
|
||||
productPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 添加产品项 */
|
||||
function addItem() {
|
||||
if (!formData.value.items) {
|
||||
formData.value.items = []
|
||||
}
|
||||
formData.value.items.push({
|
||||
warehouseId: undefined,
|
||||
warehouseName: undefined,
|
||||
productId: undefined,
|
||||
productName: undefined,
|
||||
productUnitName: undefined,
|
||||
count: undefined,
|
||||
productPrice: undefined,
|
||||
totalPrice: 0,
|
||||
remark: undefined,
|
||||
})
|
||||
}
|
||||
|
||||
/** 移除产品项 */
|
||||
function removeItem(index: number) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 计算产品项金额 */
|
||||
function calcItemTotal(item: StockInItem) {
|
||||
const count = Number(item.count) || 0
|
||||
const price = Number(item.productPrice) || 0
|
||||
item.totalPrice = count * price
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
// 校验产品清单
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.error('请添加入库产品')
|
||||
return
|
||||
}
|
||||
|
||||
for (const item of formData.value.items) {
|
||||
if (!item.warehouseId) {
|
||||
toast.error('请选择仓库')
|
||||
return
|
||||
}
|
||||
if (!item.productId) {
|
||||
toast.error('请选择产品')
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.error('请输入有效的数量')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
// 设置合计
|
||||
formData.value.totalCount = totalCount.value
|
||||
formData.value.totalPrice = totalPrice.value
|
||||
|
||||
if (props.id) {
|
||||
await updateStockIn(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createStockIn(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
// 加载供应商列表
|
||||
supplierList.value = await getSupplierSimpleList()
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await getWarehouseSimpleList()
|
||||
// 加载详情
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
388
src/pages-erp/stock-in/index.vue
Normal file
388
src/pages-erp/stock-in/index.vue
Normal file
@@ -0,0 +1,388 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="其他入库"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<view @click="searchVisible = true">
|
||||
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 快捷筛选标签 -->
|
||||
<view class="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
:class="queryParams.status === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'"
|
||||
@click="onTabChange(tab.value)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<view
|
||||
v-if="queryParams.status === tab.value"
|
||||
class="absolute bottom-0 left-1/4 w-1/2 h-4rpx rounded-2rpx bg-[#1890ff]"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 入库单列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
@click="handleDetail(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:单号 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.no || '-' }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="item.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ item.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 供应商 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">供应商</text>
|
||||
<text>{{ item.supplierName || '-' }}</text>
|
||||
</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>
|
||||
</view>
|
||||
<!-- 入库时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">入库时间</text>
|
||||
<text>{{ formatDate(item.inTime) }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#333] font-semibold">{{ formatCount(item.totalCount) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">金额</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-in:update']) && item.status !== 20"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-in:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleApprove(item.id!)"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-in:update-status']) && item.status === 20"
|
||||
size="small" type="warning" plain @click="handleReverseApprove(item.id!)"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-in:delete']) && item.status !== 20"
|
||||
size="small" type="error" plain @click="handleDelete(item.id!)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无入库单数据" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 新增按钮 -->
|
||||
<wd-fab
|
||||
v-if="hasAccessByCodes(['erp:stock-in:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">入库单号</view>
|
||||
<wd-input v-model="searchForm.no" placeholder="请输入入库单号" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">审核状态</view>
|
||||
<view class="yd-search-form-radio-group">
|
||||
<view
|
||||
v-for="opt in statusOptions"
|
||||
:key="opt.value"
|
||||
class="yd-search-form-radio"
|
||||
:class="{ 'yd-search-form-radio--active': searchForm.status === opt.value }"
|
||||
@click="searchForm.status = opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">重置</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">搜索</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockIn } from '@/api/erp/stock-in'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockIn, getStockInPage, updateStockInStatus } from '@/api/erp/stock-in'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<StockIn[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
status: undefined,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
no: undefined as string | undefined,
|
||||
status: undefined as number | undefined,
|
||||
})
|
||||
|
||||
/** 状态标签 */
|
||||
const statusTabs = [
|
||||
{ value: undefined, label: '全部' },
|
||||
{ value: 10, label: '未审核' },
|
||||
{ value: 20, label: '已审核' },
|
||||
]
|
||||
|
||||
/** 状态选项 */
|
||||
const statusOptions = [
|
||||
{ value: undefined, label: '全部' },
|
||||
{ value: 10, label: '未审核' },
|
||||
{ value: 20, label: '已审核' },
|
||||
]
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.no) conditions.push(`单号:${searchForm.no}`)
|
||||
if (searchForm.status !== undefined) {
|
||||
const statusLabel = statusOptions.find(o => o.value === searchForm.status)?.label
|
||||
if (statusLabel && statusLabel !== '全部') conditions.push(`状态:${statusLabel}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索入库单'
|
||||
})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 切换状态标签 */
|
||||
function onTabChange(status: number | undefined) {
|
||||
queryParams.value.status = status
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 查询入库单列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
if (searchForm.no) params.no = searchForm.no
|
||||
const data = await getStockInPage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
searchVisible.value = false
|
||||
queryParams.value = {
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
status: searchForm.status,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.no = undefined
|
||||
searchForm.status = undefined
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10, status: undefined }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 新增入库单 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/stock-in/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: StockIn) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-in/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
function handleDetail(item: StockIn) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-in/detail/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockInStatus(id, 20)
|
||||
toast.success('审批成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockInStatus(id, 10)
|
||||
toast.success('反审批成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockIn([id])
|
||||
toast.success('删除成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 刷新列表 */
|
||||
function refreshList() {
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
226
src/pages-erp/stock-loss/detail/index.vue
Normal file
226
src/pages-erp/stock-loss/detail/index.vue
Normal file
@@ -0,0 +1,226 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="报损单详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view class="pb-180rpx">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="报损单号" :value="detail.no || '-'" />
|
||||
<wd-cell title="报损时间" :value="formatDate(detail.lossTime)" />
|
||||
<wd-cell title="报损原因" :value="detail.reason || '-'" />
|
||||
<wd-cell title="审核状态">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="detail.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ detail.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="备注" :value="detail.remark || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(detail.totalCount)" />
|
||||
<wd-cell title="合计金额" :value="formatPrice(detail.totalPrice)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 报损产品清单 -->
|
||||
<wd-cell-group title="报损产品清单" border>
|
||||
<view v-if="!detail.items || detail.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品数据
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in detail.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '-' }}
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">仓库</text>
|
||||
<text class="text-[#666]">{{ item.warehouseName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">数量</text>
|
||||
<text class="text-[#f5222d] font-semibold">-{{ formatCount(item.count) }}</text>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#f5222d] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:update']) && detail.status === 10"
|
||||
type="primary"
|
||||
@click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:update-status']) && detail.status === 10"
|
||||
type="success"
|
||||
@click="handleApprove"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:update-status']) && detail.status === 20"
|
||||
type="warning"
|
||||
@click="handleReverseApprove"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:delete']) && detail.status === 10"
|
||||
type="error"
|
||||
@click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockLoss } from '@/api/erp/stock-loss'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockLoss, getStockLoss, updateStockLossStatus } from '@/api/erp/stock-loss'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const detail = ref<StockLoss>({})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/stock-loss/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
detail.value = await getStockLoss(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-loss/form/index?id=${props.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该报损单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockLossStatus(props.id, 20)
|
||||
toast.success('审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该报损单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockLossStatus(props.id, 10)
|
||||
toast.success('反审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该报损单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockLoss([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
385
src/pages-erp/stock-loss/form/index.vue
Normal file
385
src/pages-erp/stock-loss/form/index.vue
Normal file
@@ -0,0 +1,385 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="报损单号" :value="formData.no || '保存时自动生成'" />
|
||||
<wd-cell
|
||||
title="报损时间"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="formData.lossTime ? formatDate(formData.lossTime) : '请选择'"
|
||||
@click="datePickerVisible = true"
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.reason"
|
||||
label="报损原因"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入报损原因"
|
||||
clearable
|
||||
/>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 报损产品清单 -->
|
||||
<wd-cell-group title="报损产品清单" border>
|
||||
<view v-if="formData.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品,请点击下方按钮添加
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '请选择产品' }}
|
||||
</view>
|
||||
<wd-icon name="delete" size="40rpx" color="#f56c6c" @click="removeItem(index)" />
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="仓库"
|
||||
title-width="120rpx"
|
||||
is-link
|
||||
:value="item.warehouseName || '请选择'"
|
||||
@click="openWarehousePicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="产品"
|
||||
title-width="120rpx"
|
||||
is-link
|
||||
:value="item.productName || '请选择'"
|
||||
@click="openProductPicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.count"
|
||||
label="数量"
|
||||
label-width="120rpx"
|
||||
type="number"
|
||||
placeholder="请输入数量"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
label="单价"
|
||||
label-width="120rpx"
|
||||
type="digit"
|
||||
placeholder="请输入单价"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#f5222d] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="px-24rpx pb-24rpx">
|
||||
<wd-button type="primary" plain block @click="addItem">
|
||||
<wd-icon name="add" class="mr-8rpx" />
|
||||
添加产品
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 合计信息 -->
|
||||
<wd-cell-group title="合计信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(totalCount)" />
|
||||
<wd-cell title="合计金额" :value="formatPrice(totalPrice)" />
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 日期选择器 -->
|
||||
<wd-datetime-picker
|
||||
v-model="datePickerVisible"
|
||||
type="date"
|
||||
:value="formData.lossTime"
|
||||
@confirm="onDateConfirm"
|
||||
/>
|
||||
|
||||
<!-- 仓库选择器 -->
|
||||
<wd-picker
|
||||
v-model="warehousePickerVisible"
|
||||
:columns="warehouseColumns"
|
||||
@confirm="onWarehouseConfirm"
|
||||
/>
|
||||
|
||||
<!-- 产品选择器 -->
|
||||
<wd-picker
|
||||
v-model="productPickerVisible"
|
||||
:columns="productColumns"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { StockLoss, StockLossItem } from '@/api/erp/stock-loss'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createStockLoss, getStockLoss, updateStockLoss } from '@/api/erp/stock-loss'
|
||||
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const toast = useToast()
|
||||
const getTitle = computed(() => props.id ? '编辑报损单' : '新增报损单')
|
||||
const formLoading = ref(false)
|
||||
const formData = ref<StockLoss>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
lossTime: undefined,
|
||||
reason: undefined,
|
||||
remark: undefined,
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
lossTime: [{ required: true, message: '报损时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 仓库列表
|
||||
const warehouseList = ref<{ id: number, name: string }[]>([])
|
||||
const warehousePickerVisible = ref(false)
|
||||
const warehouseColumns = computed(() => [
|
||||
warehouseList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 产品列表
|
||||
const productList = ref<{ id: number, name: string, unitName?: string }[]>([])
|
||||
const productPickerVisible = ref(false)
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 日期选择器
|
||||
const datePickerVisible = ref(false)
|
||||
|
||||
// 当前编辑的产品项索引
|
||||
const currentItemIndex = ref(-1)
|
||||
|
||||
/** 合计数量 */
|
||||
const totalCount = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.count) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计金额 */
|
||||
const totalPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.totalPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
if (typeof dateStr === 'number') {
|
||||
const d = new Date(dateStr)
|
||||
const pad = (n: number) => n.toString().padStart(2, '0')
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
|
||||
}
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/stock-loss/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getStockLoss(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 日期确认 */
|
||||
function onDateConfirm({ value }: any) {
|
||||
formData.value.lossTime = value
|
||||
datePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开仓库选择器 */
|
||||
function openWarehousePicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
warehousePickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 仓库确认 */
|
||||
function onWarehouseConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.warehouseId = value?.[0]
|
||||
const warehouse = warehouseList.value.find(w => w.id === item.warehouseId)
|
||||
item.warehouseName = warehouse?.name
|
||||
}
|
||||
warehousePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开产品选择器 */
|
||||
function openProductPicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
productPickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 产品确认 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.productId = value?.[0]
|
||||
const product = productList.value.find(p => p.id === item.productId)
|
||||
item.productName = product?.name
|
||||
item.productUnitName = product?.unitName
|
||||
}
|
||||
productPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 添加产品项 */
|
||||
function addItem() {
|
||||
if (!formData.value.items) {
|
||||
formData.value.items = []
|
||||
}
|
||||
formData.value.items.push({
|
||||
warehouseId: undefined,
|
||||
warehouseName: undefined,
|
||||
productId: undefined,
|
||||
productName: undefined,
|
||||
productUnitName: undefined,
|
||||
count: undefined,
|
||||
productPrice: undefined,
|
||||
totalPrice: 0,
|
||||
})
|
||||
}
|
||||
|
||||
/** 移除产品项 */
|
||||
function removeItem(index: number) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 计算产品项金额 */
|
||||
function calcItemTotal(item: StockLossItem) {
|
||||
const count = Number(item.count) || 0
|
||||
const price = Number(item.productPrice) || 0
|
||||
item.totalPrice = count * price
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
// 校验产品清单
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.error('请添加报损产品')
|
||||
return
|
||||
}
|
||||
|
||||
for (const item of formData.value.items) {
|
||||
if (!item.warehouseId) {
|
||||
toast.error('请选择仓库')
|
||||
return
|
||||
}
|
||||
if (!item.productId) {
|
||||
toast.error('请选择产品')
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.error('请输入有效的数量')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
// 设置合计
|
||||
formData.value.totalCount = totalCount.value
|
||||
formData.value.totalPrice = totalPrice.value
|
||||
|
||||
if (props.id) {
|
||||
await updateStockLoss(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createStockLoss(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await getWarehouseSimpleList()
|
||||
// 加载详情
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
388
src/pages-erp/stock-loss/index.vue
Normal file
388
src/pages-erp/stock-loss/index.vue
Normal file
@@ -0,0 +1,388 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="库存报损"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<view @click="searchVisible = true">
|
||||
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 快捷筛选标签 -->
|
||||
<view class="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
:class="queryParams.status === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'"
|
||||
@click="onTabChange(tab.value)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<view
|
||||
v-if="queryParams.status === tab.value"
|
||||
class="absolute bottom-0 left-1/4 w-1/2 h-4rpx rounded-2rpx bg-[#1890ff]"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 报损单列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
@click="handleDetail(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:单号 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.no || '-' }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="item.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ item.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</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>
|
||||
</view>
|
||||
<!-- 报损时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">报损时间</text>
|
||||
<text>{{ formatDate(item.lossTime) }}</text>
|
||||
</view>
|
||||
<!-- 报损原因 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">报损原因</text>
|
||||
<text>{{ item.reason || '-' }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#f5222d] font-semibold">{{ formatCount(item.totalCount) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#f5222d] font-semibold">{{ formatPrice(item.totalPrice) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">金额</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:update']) && item.status === 10"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleApprove(item.id!)"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:update-status']) && item.status === 20"
|
||||
size="small" type="warning" plain @click="handleReverseApprove(item.id!)"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:delete']) && item.status === 10"
|
||||
size="small" type="error" plain @click="handleDelete(item.id!)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无报损单数据" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 新增按钮 -->
|
||||
<wd-fab
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">报损单号</view>
|
||||
<wd-input v-model="searchForm.no" placeholder="请输入报损单号" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">审核状态</view>
|
||||
<view class="yd-search-form-radio-group">
|
||||
<view
|
||||
v-for="opt in statusOptions"
|
||||
:key="opt.value"
|
||||
class="yd-search-form-radio"
|
||||
:class="{ 'yd-search-form-radio--active': searchForm.status === opt.value }"
|
||||
@click="searchForm.status = opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">重置</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">搜索</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockLoss } from '@/api/erp/stock-loss'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockLoss, getStockLossPage, updateStockLossStatus } from '@/api/erp/stock-loss'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<StockLoss[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
status: undefined,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
no: undefined as string | undefined,
|
||||
status: undefined as number | undefined,
|
||||
})
|
||||
|
||||
/** 状态标签 */
|
||||
const statusTabs = [
|
||||
{ value: undefined, label: '全部' },
|
||||
{ value: 10, label: '未审核' },
|
||||
{ value: 20, label: '已审核' },
|
||||
]
|
||||
|
||||
/** 状态选项 */
|
||||
const statusOptions = [
|
||||
{ value: undefined, label: '全部' },
|
||||
{ value: 10, label: '未审核' },
|
||||
{ value: 20, label: '已审核' },
|
||||
]
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.no) conditions.push(`单号:${searchForm.no}`)
|
||||
if (searchForm.status !== undefined) {
|
||||
const statusLabel = statusOptions.find(o => o.value === searchForm.status)?.label
|
||||
if (statusLabel && statusLabel !== '全部') conditions.push(`状态:${statusLabel}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索报损单'
|
||||
})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 切换状态标签 */
|
||||
function onTabChange(status: number | undefined) {
|
||||
queryParams.value.status = status
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 查询报损单列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
if (searchForm.no) params.no = searchForm.no
|
||||
const data = await getStockLossPage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
searchVisible.value = false
|
||||
queryParams.value = {
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
status: searchForm.status,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.no = undefined
|
||||
searchForm.status = undefined
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10, status: undefined }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 新增报损单 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/stock-loss/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: StockLoss) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-loss/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
function handleDetail(item: StockLoss) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-loss/detail/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该报损单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockLossStatus(id, 20)
|
||||
toast.success('审批成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该报损单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockLossStatus(id, 10)
|
||||
toast.success('反审批成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该报损单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockLoss([id])
|
||||
toast.success('删除成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 刷新列表 */
|
||||
function refreshList() {
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
229
src/pages-erp/stock-move/detail/index.vue
Normal file
229
src/pages-erp/stock-move/detail/index.vue
Normal file
@@ -0,0 +1,229 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="调拨单详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view class="pb-180rpx">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="调拨单号" :value="detail.no || '-'" />
|
||||
<wd-cell title="调拨时间" :value="formatDate(detail.moveTime)" />
|
||||
<wd-cell title="审核状态">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="detail.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ detail.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="备注" :value="detail.remark || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="调拨数量" :value="formatCount(detail.totalCount)" />
|
||||
<wd-cell title="调拨金额" :value="formatPrice(detail.totalPrice)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 调拨产品清单 -->
|
||||
<wd-cell-group title="调拨产品清单" border>
|
||||
<view v-if="!detail.items || detail.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品数据
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in detail.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '-' }}
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">调出仓库</text>
|
||||
<text class="text-[#f5222d]">{{ item.fromWarehouseName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">调入仓库</text>
|
||||
<text class="text-[#52c41a]">{{ item.toWarehouseName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">数量</text>
|
||||
<text class="text-[#666]">{{ formatCount(item.count) }}</text>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-move:update']) && detail.status === 10"
|
||||
type="primary"
|
||||
@click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-move:update-status']) && detail.status === 10"
|
||||
type="success"
|
||||
@click="handleApprove"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-move:update-status']) && detail.status === 20"
|
||||
type="warning"
|
||||
@click="handleReverseApprove"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-move:delete']) && detail.status === 10"
|
||||
type="error"
|
||||
@click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockMove } from '@/api/erp/stock-move'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockMove, getStockMove, updateStockMoveStatus } from '@/api/erp/stock-move'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const detail = ref<StockMove>({})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/stock-move/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
detail.value = await getStockMove(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-move/form/index?id=${props.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该调拨单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockMoveStatus(props.id, 20)
|
||||
toast.success('审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该调拨单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockMoveStatus(props.id, 10)
|
||||
toast.success('反审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该调拨单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockMove([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
421
src/pages-erp/stock-move/form/index.vue
Normal file
421
src/pages-erp/stock-move/form/index.vue
Normal file
@@ -0,0 +1,421 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="调拨单号" :value="formData.no || '保存时自动生成'" />
|
||||
<wd-cell
|
||||
title="调拨时间"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="formData.moveTime ? formatDate(formData.moveTime) : '请选择'"
|
||||
@click="datePickerVisible = true"
|
||||
/>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 调拨产品清单 -->
|
||||
<wd-cell-group title="调拨产品清单" border>
|
||||
<view v-if="formData.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品,请点击下方按钮添加
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '请选择产品' }}
|
||||
</view>
|
||||
<wd-icon name="delete" size="40rpx" color="#f56c6c" @click="removeItem(index)" />
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="调出仓库"
|
||||
title-width="140rpx"
|
||||
is-link
|
||||
:value="item.fromWarehouseName || '请选择'"
|
||||
@click="openFromWarehousePicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="调入仓库"
|
||||
title-width="140rpx"
|
||||
is-link
|
||||
:value="item.toWarehouseName || '请选择'"
|
||||
@click="openToWarehousePicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="产品"
|
||||
title-width="140rpx"
|
||||
is-link
|
||||
:value="item.productName || '请选择'"
|
||||
@click="openProductPicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.count"
|
||||
label="数量"
|
||||
label-width="140rpx"
|
||||
type="number"
|
||||
placeholder="请输入数量"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
label="单价"
|
||||
label-width="140rpx"
|
||||
type="digit"
|
||||
placeholder="请输入单价"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="px-24rpx pb-24rpx">
|
||||
<wd-button type="primary" plain block @click="addItem">
|
||||
<wd-icon name="add" class="mr-8rpx" />
|
||||
添加产品
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 合计信息 -->
|
||||
<wd-cell-group title="合计信息" border>
|
||||
<wd-cell title="调拨数量" :value="formatCount(totalCount)" />
|
||||
<wd-cell title="调拨金额" :value="formatPrice(totalPrice)" />
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 日期选择器 -->
|
||||
<wd-datetime-picker
|
||||
v-model="datePickerVisible"
|
||||
type="date"
|
||||
:value="formData.moveTime"
|
||||
@confirm="onDateConfirm"
|
||||
/>
|
||||
|
||||
<!-- 调出仓库选择器 -->
|
||||
<wd-picker
|
||||
v-model="fromWarehousePickerVisible"
|
||||
:columns="warehouseColumns"
|
||||
@confirm="onFromWarehouseConfirm"
|
||||
/>
|
||||
|
||||
<!-- 调入仓库选择器 -->
|
||||
<wd-picker
|
||||
v-model="toWarehousePickerVisible"
|
||||
:columns="warehouseColumns"
|
||||
@confirm="onToWarehouseConfirm"
|
||||
/>
|
||||
|
||||
<!-- 产品选择器 -->
|
||||
<wd-picker
|
||||
v-model="productPickerVisible"
|
||||
:columns="productColumns"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { StockMove, StockMoveItem } from '@/api/erp/stock-move'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createStockMove, getStockMove, updateStockMove } from '@/api/erp/stock-move'
|
||||
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const toast = useToast()
|
||||
const getTitle = computed(() => props.id ? '编辑调拨单' : '新增调拨单')
|
||||
const formLoading = ref(false)
|
||||
const formData = ref<StockMove>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
moveTime: undefined,
|
||||
remark: undefined,
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
moveTime: [{ required: true, message: '调拨时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 仓库列表
|
||||
const warehouseList = ref<{ id: number, name: string }[]>([])
|
||||
const fromWarehousePickerVisible = ref(false)
|
||||
const toWarehousePickerVisible = ref(false)
|
||||
const warehouseColumns = computed(() => [
|
||||
warehouseList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 产品列表
|
||||
const productList = ref<{ id: number, name: string, unitName?: string }[]>([])
|
||||
const productPickerVisible = ref(false)
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 日期选择器
|
||||
const datePickerVisible = ref(false)
|
||||
|
||||
// 当前编辑的产品项索引
|
||||
const currentItemIndex = ref(-1)
|
||||
|
||||
/** 合计数量 */
|
||||
const totalCount = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.count) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计金额 */
|
||||
const totalPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.totalPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
if (typeof dateStr === 'number') {
|
||||
const d = new Date(dateStr)
|
||||
const pad = (n: number) => n.toString().padStart(2, '0')
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
|
||||
}
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/stock-move/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getStockMove(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 日期确认 */
|
||||
function onDateConfirm({ value }: any) {
|
||||
formData.value.moveTime = value
|
||||
datePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开调出仓库选择器 */
|
||||
function openFromWarehousePicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
fromWarehousePickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 调出仓库确认 */
|
||||
function onFromWarehouseConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.fromWarehouseId = value?.[0]
|
||||
const warehouse = warehouseList.value.find(w => w.id === item.fromWarehouseId)
|
||||
item.fromWarehouseName = warehouse?.name
|
||||
}
|
||||
fromWarehousePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开调入仓库选择器 */
|
||||
function openToWarehousePicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
toWarehousePickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 调入仓库确认 */
|
||||
function onToWarehouseConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.toWarehouseId = value?.[0]
|
||||
const warehouse = warehouseList.value.find(w => w.id === item.toWarehouseId)
|
||||
item.toWarehouseName = warehouse?.name
|
||||
}
|
||||
toWarehousePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开产品选择器 */
|
||||
function openProductPicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
productPickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 产品确认 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.productId = value?.[0]
|
||||
const product = productList.value.find(p => p.id === item.productId)
|
||||
item.productName = product?.name
|
||||
item.productUnitName = product?.unitName
|
||||
}
|
||||
productPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 添加产品项 */
|
||||
function addItem() {
|
||||
if (!formData.value.items) {
|
||||
formData.value.items = []
|
||||
}
|
||||
formData.value.items.push({
|
||||
fromWarehouseId: undefined,
|
||||
fromWarehouseName: undefined,
|
||||
toWarehouseId: undefined,
|
||||
toWarehouseName: undefined,
|
||||
productId: undefined,
|
||||
productName: undefined,
|
||||
productUnitName: undefined,
|
||||
count: undefined,
|
||||
productPrice: undefined,
|
||||
totalPrice: 0,
|
||||
})
|
||||
}
|
||||
|
||||
/** 移除产品项 */
|
||||
function removeItem(index: number) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 计算产品项金额 */
|
||||
function calcItemTotal(item: StockMoveItem) {
|
||||
const count = Number(item.count) || 0
|
||||
const price = Number(item.productPrice) || 0
|
||||
item.totalPrice = count * price
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
// 校验产品清单
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.error('请添加调拨产品')
|
||||
return
|
||||
}
|
||||
|
||||
for (const item of formData.value.items) {
|
||||
if (!item.fromWarehouseId) {
|
||||
toast.error('请选择调出仓库')
|
||||
return
|
||||
}
|
||||
if (!item.toWarehouseId) {
|
||||
toast.error('请选择调入仓库')
|
||||
return
|
||||
}
|
||||
if (item.fromWarehouseId === item.toWarehouseId) {
|
||||
toast.error('调出仓库和调入仓库不能相同')
|
||||
return
|
||||
}
|
||||
if (!item.productId) {
|
||||
toast.error('请选择产品')
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.error('请输入有效的数量')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
// 设置合计
|
||||
formData.value.totalCount = totalCount.value
|
||||
formData.value.totalPrice = totalPrice.value
|
||||
|
||||
if (props.id) {
|
||||
await updateStockMove(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createStockMove(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await getWarehouseSimpleList()
|
||||
// 加载详情
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
383
src/pages-erp/stock-move/index.vue
Normal file
383
src/pages-erp/stock-move/index.vue
Normal file
@@ -0,0 +1,383 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="库存调拨"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<view @click="searchVisible = true">
|
||||
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 快捷筛选标签 -->
|
||||
<view class="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
:class="queryParams.status === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'"
|
||||
@click="onTabChange(tab.value)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<view
|
||||
v-if="queryParams.status === tab.value"
|
||||
class="absolute bottom-0 left-1/4 w-1/2 h-4rpx rounded-2rpx bg-[#1890ff]"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 调拨单列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
@click="handleDetail(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:单号 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.no || '-' }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="item.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ item.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</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>
|
||||
</view>
|
||||
<!-- 调拨时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">调拨时间</text>
|
||||
<text>{{ formatDate(item.moveTime) }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#333] font-semibold">{{ formatCount(item.totalCount) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">调拨数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">调拨金额</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-move:update']) && item.status === 10"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-move:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleApprove(item.id!)"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-move:update-status']) && item.status === 20"
|
||||
size="small" type="warning" plain @click="handleReverseApprove(item.id!)"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-move:delete']) && item.status === 10"
|
||||
size="small" type="error" plain @click="handleDelete(item.id!)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无调拨单数据" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 新增按钮 -->
|
||||
<wd-fab
|
||||
v-if="hasAccessByCodes(['erp:stock-move:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">调拨单号</view>
|
||||
<wd-input v-model="searchForm.no" placeholder="请输入调拨单号" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">审核状态</view>
|
||||
<view class="yd-search-form-radio-group">
|
||||
<view
|
||||
v-for="opt in statusOptions"
|
||||
:key="opt.value"
|
||||
class="yd-search-form-radio"
|
||||
:class="{ 'yd-search-form-radio--active': searchForm.status === opt.value }"
|
||||
@click="searchForm.status = opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">重置</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">搜索</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockMove } from '@/api/erp/stock-move'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockMove, getStockMovePage, updateStockMoveStatus } from '@/api/erp/stock-move'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<StockMove[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
status: undefined,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
no: undefined as string | undefined,
|
||||
status: undefined as number | undefined,
|
||||
})
|
||||
|
||||
/** 状态标签 */
|
||||
const statusTabs = [
|
||||
{ value: undefined, label: '全部' },
|
||||
{ value: 10, label: '未审核' },
|
||||
{ value: 20, label: '已审核' },
|
||||
]
|
||||
|
||||
/** 状态选项 */
|
||||
const statusOptions = [
|
||||
{ value: undefined, label: '全部' },
|
||||
{ value: 10, label: '未审核' },
|
||||
{ value: 20, label: '已审核' },
|
||||
]
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.no) conditions.push(`单号:${searchForm.no}`)
|
||||
if (searchForm.status !== undefined) {
|
||||
const statusLabel = statusOptions.find(o => o.value === searchForm.status)?.label
|
||||
if (statusLabel && statusLabel !== '全部') conditions.push(`状态:${statusLabel}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索调拨单'
|
||||
})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 切换状态标签 */
|
||||
function onTabChange(status: number | undefined) {
|
||||
queryParams.value.status = status
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 查询调拨单列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
if (searchForm.no) params.no = searchForm.no
|
||||
const data = await getStockMovePage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
searchVisible.value = false
|
||||
queryParams.value = {
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
status: searchForm.status,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.no = undefined
|
||||
searchForm.status = undefined
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10, status: undefined }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 新增调拨单 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/stock-move/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: StockMove) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-move/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
function handleDetail(item: StockMove) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-move/detail/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该调拨单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockMoveStatus(id, 20)
|
||||
toast.success('审批成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该调拨单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockMoveStatus(id, 10)
|
||||
toast.success('反审批成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该调拨单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockMove([id])
|
||||
toast.success('删除成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 刷新列表 */
|
||||
function refreshList() {
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
238
src/pages-erp/stock-out/detail/index.vue
Normal file
238
src/pages-erp/stock-out/detail/index.vue
Normal file
@@ -0,0 +1,238 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="出库单详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view class="pb-180rpx">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="出库单号" :value="detail.no || '-'" />
|
||||
<wd-cell title="出库时间" :value="formatDate(detail.outTime)" />
|
||||
<wd-cell title="客户" :value="detail.customerName || '-'" />
|
||||
<wd-cell title="审核状态">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="detail.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ detail.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="备注" :value="detail.remark || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(detail.totalCount)" />
|
||||
<wd-cell title="合计金额" :value="formatPrice(detail.totalPrice)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 出库产品清单 -->
|
||||
<wd-cell-group title="出库产品清单" border>
|
||||
<view v-if="!detail.items || detail.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品数据
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in detail.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '-' }}
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">仓库</text>
|
||||
<text class="text-[#666]">{{ item.warehouseName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">单位</text>
|
||||
<text class="text-[#666]">{{ item.productUnitName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">数量</text>
|
||||
<text class="text-[#666]">{{ formatCount(item.count) }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">单价</text>
|
||||
<text class="text-[#666]">{{ formatPrice(item.productPrice) }}</text>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#f5222d] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
<view v-if="item.remark" class="mt-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">备注</text>
|
||||
<text class="text-[#666]">{{ item.remark }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-out:update']) && detail.status !== 20"
|
||||
type="primary"
|
||||
@click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-out:update-status']) && detail.status === 10"
|
||||
type="success"
|
||||
@click="handleApprove"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-out:update-status']) && detail.status === 20"
|
||||
type="warning"
|
||||
@click="handleReverseApprove"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-out:delete']) && detail.status !== 20"
|
||||
type="error"
|
||||
@click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockOut } from '@/api/erp/stock-out'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockOut, getStockOut, updateStockOutStatus } from '@/api/erp/stock-out'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const detail = ref<StockOut>({})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/stock-out/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
detail.value = await getStockOut(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-out/form/index?id=${props.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该出库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockOutStatus(props.id, 20)
|
||||
toast.success('审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该出库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockOutStatus(props.id, 10)
|
||||
toast.success('反审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该出库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockOut([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
421
src/pages-erp/stock-out/form/index.vue
Normal file
421
src/pages-erp/stock-out/form/index.vue
Normal file
@@ -0,0 +1,421 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="出库单号" :value="formData.no || '保存时自动生成'" />
|
||||
<wd-cell
|
||||
title="出库时间"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="formData.outTime ? formatDate(formData.outTime) : '请选择'"
|
||||
@click="datePickerVisible = true"
|
||||
/>
|
||||
<wd-cell
|
||||
title="客户"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="getCustomerName()"
|
||||
@click="customerPickerVisible = true"
|
||||
/>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 出库产品清单 -->
|
||||
<wd-cell-group title="出库产品清单" border>
|
||||
<view v-if="formData.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品,请点击下方按钮添加
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '请选择产品' }}
|
||||
</view>
|
||||
<wd-icon name="delete" size="40rpx" color="#f56c6c" @click="removeItem(index)" />
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="仓库"
|
||||
title-width="120rpx"
|
||||
is-link
|
||||
:value="item.warehouseName || '请选择'"
|
||||
@click="openWarehousePicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="产品"
|
||||
title-width="120rpx"
|
||||
is-link
|
||||
:value="item.productName || '请选择'"
|
||||
@click="openProductPicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.count"
|
||||
label="数量"
|
||||
label-width="120rpx"
|
||||
type="number"
|
||||
placeholder="请输入数量"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
label="单价"
|
||||
label-width="120rpx"
|
||||
type="digit"
|
||||
placeholder="请输入单价"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#f5222d] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
<view class="mt-12rpx">
|
||||
<wd-input
|
||||
v-model="item.remark"
|
||||
label="备注"
|
||||
label-width="120rpx"
|
||||
placeholder="请输入备注"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="px-24rpx pb-24rpx">
|
||||
<wd-button type="primary" plain block @click="addItem">
|
||||
<wd-icon name="add" class="mr-8rpx" />
|
||||
添加产品
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 合计信息 -->
|
||||
<wd-cell-group title="合计信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(totalCount)" />
|
||||
<wd-cell title="合计金额" :value="formatPrice(totalPrice)" />
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 日期选择器 -->
|
||||
<wd-datetime-picker
|
||||
v-model="datePickerVisible"
|
||||
type="date"
|
||||
:value="formData.outTime"
|
||||
@confirm="onDateConfirm"
|
||||
/>
|
||||
|
||||
<!-- 客户选择器 -->
|
||||
<wd-picker
|
||||
v-model="customerPickerVisible"
|
||||
:columns="customerColumns"
|
||||
@confirm="onCustomerConfirm"
|
||||
/>
|
||||
|
||||
<!-- 仓库选择器 -->
|
||||
<wd-picker
|
||||
v-model="warehousePickerVisible"
|
||||
:columns="warehouseColumns"
|
||||
@confirm="onWarehouseConfirm"
|
||||
/>
|
||||
|
||||
<!-- 产品选择器 -->
|
||||
<wd-picker
|
||||
v-model="productPickerVisible"
|
||||
:columns="productColumns"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { StockOut, StockOutItem } from '@/api/erp/stock-out'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createStockOut, getStockOut, updateStockOut } from '@/api/erp/stock-out'
|
||||
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const toast = useToast()
|
||||
const getTitle = computed(() => props.id ? '编辑出库单' : '新增出库单')
|
||||
const formLoading = ref(false)
|
||||
const formData = ref<StockOut>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
customerId: undefined,
|
||||
outTime: undefined,
|
||||
remark: undefined,
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
outTime: [{ required: true, message: '出库时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 客户列表
|
||||
const customerList = ref<{ id: number, name: string }[]>([])
|
||||
const customerPickerVisible = ref(false)
|
||||
const customerColumns = computed(() => [
|
||||
customerList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 仓库列表
|
||||
const warehouseList = ref<{ id: number, name: string }[]>([])
|
||||
const warehousePickerVisible = ref(false)
|
||||
const warehouseColumns = computed(() => [
|
||||
warehouseList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 产品列表
|
||||
const productList = ref<{ id: number, name: string, unitName?: string }[]>([])
|
||||
const productPickerVisible = ref(false)
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 日期选择器
|
||||
const datePickerVisible = ref(false)
|
||||
|
||||
// 当前编辑的产品项索引
|
||||
const currentItemIndex = ref(-1)
|
||||
|
||||
/** 合计数量 */
|
||||
const totalCount = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.count) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计金额 */
|
||||
const totalPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.totalPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 获取客户名称 */
|
||||
function getCustomerName() {
|
||||
if (!formData.value.customerId) return '请选择'
|
||||
const customer = customerList.value.find(c => c.id === formData.value.customerId)
|
||||
return customer?.name || '请选择'
|
||||
}
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
if (typeof dateStr === 'number') {
|
||||
const d = new Date(dateStr)
|
||||
const pad = (n: number) => n.toString().padStart(2, '0')
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
|
||||
}
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/stock-out/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getStockOut(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 日期确认 */
|
||||
function onDateConfirm({ value }: any) {
|
||||
formData.value.outTime = value
|
||||
datePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 客户确认 */
|
||||
function onCustomerConfirm({ value }: any) {
|
||||
formData.value.customerId = value?.[0]
|
||||
customerPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开仓库选择器 */
|
||||
function openWarehousePicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
warehousePickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 仓库确认 */
|
||||
function onWarehouseConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.warehouseId = value?.[0]
|
||||
const warehouse = warehouseList.value.find(w => w.id === item.warehouseId)
|
||||
item.warehouseName = warehouse?.name
|
||||
}
|
||||
warehousePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开产品选择器 */
|
||||
function openProductPicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
productPickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 产品确认 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.productId = value?.[0]
|
||||
const product = productList.value.find(p => p.id === item.productId)
|
||||
item.productName = product?.name
|
||||
item.productUnitName = product?.unitName
|
||||
}
|
||||
productPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 添加产品项 */
|
||||
function addItem() {
|
||||
if (!formData.value.items) {
|
||||
formData.value.items = []
|
||||
}
|
||||
formData.value.items.push({
|
||||
warehouseId: undefined,
|
||||
warehouseName: undefined,
|
||||
productId: undefined,
|
||||
productName: undefined,
|
||||
productUnitName: undefined,
|
||||
count: undefined,
|
||||
productPrice: undefined,
|
||||
totalPrice: 0,
|
||||
remark: undefined,
|
||||
})
|
||||
}
|
||||
|
||||
/** 移除产品项 */
|
||||
function removeItem(index: number) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 计算产品项金额 */
|
||||
function calcItemTotal(item: StockOutItem) {
|
||||
const count = Number(item.count) || 0
|
||||
const price = Number(item.productPrice) || 0
|
||||
item.totalPrice = count * price
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
// 校验产品清单
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.error('请添加出库产品')
|
||||
return
|
||||
}
|
||||
|
||||
for (const item of formData.value.items) {
|
||||
if (!item.warehouseId) {
|
||||
toast.error('请选择仓库')
|
||||
return
|
||||
}
|
||||
if (!item.productId) {
|
||||
toast.error('请选择产品')
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.error('请输入有效的数量')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
// 设置合计
|
||||
formData.value.totalCount = totalCount.value
|
||||
formData.value.totalPrice = totalPrice.value
|
||||
|
||||
if (props.id) {
|
||||
await updateStockOut(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createStockOut(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await getWarehouseSimpleList()
|
||||
// 加载详情
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
388
src/pages-erp/stock-out/index.vue
Normal file
388
src/pages-erp/stock-out/index.vue
Normal file
@@ -0,0 +1,388 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="其他出库"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<view @click="searchVisible = true">
|
||||
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 快捷筛选标签 -->
|
||||
<view class="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
:class="queryParams.status === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'"
|
||||
@click="onTabChange(tab.value)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<view
|
||||
v-if="queryParams.status === tab.value"
|
||||
class="absolute bottom-0 left-1/4 w-1/2 h-4rpx rounded-2rpx bg-[#1890ff]"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 出库单列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
@click="handleDetail(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:单号 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.no || '-' }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="item.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ item.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 客户 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">客户</text>
|
||||
<text>{{ item.customerName || '-' }}</text>
|
||||
</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>
|
||||
</view>
|
||||
<!-- 出库时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">出库时间</text>
|
||||
<text>{{ formatDate(item.outTime) }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#333] font-semibold">{{ formatCount(item.totalCount) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#f5222d] font-semibold">{{ formatPrice(item.totalPrice) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">金额</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-out:update']) && item.status !== 20"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-out:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleApprove(item.id!)"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-out:update-status']) && item.status === 20"
|
||||
size="small" type="warning" plain @click="handleReverseApprove(item.id!)"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-out:delete']) && item.status !== 20"
|
||||
size="small" type="error" plain @click="handleDelete(item.id!)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无出库单数据" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 新增按钮 -->
|
||||
<wd-fab
|
||||
v-if="hasAccessByCodes(['erp:stock-out:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">出库单号</view>
|
||||
<wd-input v-model="searchForm.no" placeholder="请输入出库单号" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">审核状态</view>
|
||||
<view class="yd-search-form-radio-group">
|
||||
<view
|
||||
v-for="opt in statusOptions"
|
||||
:key="opt.value"
|
||||
class="yd-search-form-radio"
|
||||
:class="{ 'yd-search-form-radio--active': searchForm.status === opt.value }"
|
||||
@click="searchForm.status = opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">重置</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">搜索</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockOut } from '@/api/erp/stock-out'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockOut, getStockOutPage, updateStockOutStatus } from '@/api/erp/stock-out'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<StockOut[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
status: undefined,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
no: undefined as string | undefined,
|
||||
status: undefined as number | undefined,
|
||||
})
|
||||
|
||||
/** 状态标签 */
|
||||
const statusTabs = [
|
||||
{ value: undefined, label: '全部' },
|
||||
{ value: 10, label: '未审核' },
|
||||
{ value: 20, label: '已审核' },
|
||||
]
|
||||
|
||||
/** 状态选项 */
|
||||
const statusOptions = [
|
||||
{ value: undefined, label: '全部' },
|
||||
{ value: 10, label: '未审核' },
|
||||
{ value: 20, label: '已审核' },
|
||||
]
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.no) conditions.push(`单号:${searchForm.no}`)
|
||||
if (searchForm.status !== undefined) {
|
||||
const statusLabel = statusOptions.find(o => o.value === searchForm.status)?.label
|
||||
if (statusLabel && statusLabel !== '全部') conditions.push(`状态:${statusLabel}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索出库单'
|
||||
})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化金额 */
|
||||
function formatPrice(price?: number) {
|
||||
if (price === undefined || price === null) return '-'
|
||||
return `¥${price.toFixed(2)}`
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateStr?: string) {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 切换状态标签 */
|
||||
function onTabChange(status: number | undefined) {
|
||||
queryParams.value.status = status
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 查询出库单列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
if (searchForm.no) params.no = searchForm.no
|
||||
const data = await getStockOutPage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
searchVisible.value = false
|
||||
queryParams.value = {
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
status: searchForm.status,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.no = undefined
|
||||
searchForm.status = undefined
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10, status: undefined }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 新增出库单 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/stock-out/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: StockOut) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-out/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
function handleDetail(item: StockOut) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-out/detail/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该出库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockOutStatus(id, 20)
|
||||
toast.success('审批成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该出库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockOutStatus(id, 10)
|
||||
toast.success('反审批成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该出库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockOut([id])
|
||||
toast.success('删除成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 刷新列表 */
|
||||
function refreshList() {
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
293
src/pages-erp/stock-record/index.vue
Normal file
293
src/pages-erp/stock-record/index.vue
Normal file
@@ -0,0 +1,293 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="库存记录"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<view @click="searchVisible = true">
|
||||
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 库存记录列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:业务单号 + 业务类型 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.bizNo || '-' }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getBizTypeClass(item.bizType)"
|
||||
>
|
||||
{{ getBizTypeLabel(item.bizType) }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 产品 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">产品</text>
|
||||
<text>{{ item.productName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 分类 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">分类</text>
|
||||
<text>{{ item.categoryName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 仓库 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">仓库</text>
|
||||
<text>{{ item.warehouseName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 出入库日期 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">出入库日期</text>
|
||||
<text>{{ formatDate(item.createTime) }}</text>
|
||||
</view>
|
||||
<!-- 操作人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">操作人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view
|
||||
class="text-32rpx font-semibold"
|
||||
:class="(item.count ?? 0) >= 0 ? 'text-[#52c41a]' : 'text-[#f5222d]'"
|
||||
>
|
||||
{{ formatCount(item.count) }}
|
||||
</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">出入库数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#1890ff] font-semibold">{{ formatCount(item.totalCount) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">库存量</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无库存记录" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">业务单号</view>
|
||||
<wd-input v-model="searchForm.bizNo" placeholder="请输入业务单号" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">操作类型</view>
|
||||
<wd-picker
|
||||
v-model="searchForm.bizType"
|
||||
:columns="bizTypeColumns"
|
||||
label=""
|
||||
placeholder="请选择操作类型"
|
||||
@confirm="onBizTypeConfirm"
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">仓库</view>
|
||||
<wd-picker
|
||||
v-model="searchForm.warehouseId"
|
||||
:columns="warehouseColumns"
|
||||
label=""
|
||||
placeholder="请选择仓库"
|
||||
@confirm="onWarehouseConfirm"
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">重置</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">搜索</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockRecord } from '@/api/erp/stock-record'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { BIZ_TYPE_OPTIONS, getStockRecordPage } from '@/api/erp/stock-record'
|
||||
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const total = ref(0)
|
||||
const list = ref<StockRecord[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
bizNo: undefined as string | undefined,
|
||||
bizType: undefined as number | undefined,
|
||||
warehouseId: undefined as number | undefined,
|
||||
})
|
||||
|
||||
// 仓库列表
|
||||
const warehouseList = ref<{ id: number, name: string }[]>([])
|
||||
|
||||
/** 业务类型下拉列 */
|
||||
const bizTypeColumns = computed(() => [
|
||||
[{ value: '', label: '全部' }, ...BIZ_TYPE_OPTIONS.map(v => ({ value: v.value, label: v.label }))],
|
||||
])
|
||||
|
||||
/** 仓库下拉列 */
|
||||
const warehouseColumns = computed(() => [
|
||||
[{ value: '', label: '全部' }, ...warehouseList.value.map(v => ({ value: v.id, label: v.name }))],
|
||||
])
|
||||
|
||||
/** 业务类型选择回调 */
|
||||
function onBizTypeConfirm({ value }: any) {
|
||||
searchForm.bizType = value?.[0] || undefined
|
||||
}
|
||||
|
||||
/** 仓库选择回调 */
|
||||
function onWarehouseConfirm({ value }: any) {
|
||||
searchForm.warehouseId = value?.[0] || undefined
|
||||
}
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.bizNo) conditions.push(`单号:${searchForm.bizNo}`)
|
||||
if (searchForm.bizType !== undefined) {
|
||||
const bizTypeLabel = BIZ_TYPE_OPTIONS.find(o => o.value === searchForm.bizType)?.label
|
||||
if (bizTypeLabel) conditions.push(`类型:${bizTypeLabel}`)
|
||||
}
|
||||
if (searchForm.warehouseId) {
|
||||
const warehouse = warehouseList.value.find(w => w.id === searchForm.warehouseId)
|
||||
if (warehouse) conditions.push(`仓库:${warehouse.name}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索库存记录'
|
||||
})
|
||||
|
||||
/** 获取业务类型标签 */
|
||||
function getBizTypeLabel(bizType?: number) {
|
||||
if (bizType === undefined) return '-'
|
||||
return BIZ_TYPE_OPTIONS.find(o => o.value === bizType)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取业务类型样式 */
|
||||
function getBizTypeClass(bizType?: number) {
|
||||
if (bizType === undefined) return 'bg-[#f0f0f0] text-[#666]'
|
||||
// 入库类型:绿色
|
||||
if ([1, 4, 10].includes(bizType)) return 'bg-[#f6ffed] text-[#52c41a]'
|
||||
// 出库类型:红色
|
||||
if ([2, 3, 11].includes(bizType)) return 'bg-[#fff1f0] text-[#f5222d]'
|
||||
// 其他:蓝色
|
||||
return 'bg-[#e6f7ff] text-[#1890ff]'
|
||||
}
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count >= 0 ? `+${count.toFixed(2)}` : count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(timestamp?: number) {
|
||||
if (!timestamp) return '-'
|
||||
const d = new Date(timestamp)
|
||||
const pad = (n: number) => n.toString().padStart(2, '0')
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询库存记录列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params: Record<string, any> = { ...queryParams.value }
|
||||
if (searchForm.bizNo) params.bizNo = searchForm.bizNo
|
||||
if (searchForm.bizType !== undefined) params.bizType = searchForm.bizType
|
||||
if (searchForm.warehouseId) params.warehouseId = searchForm.warehouseId
|
||||
const data = await getStockRecordPage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
searchVisible.value = false
|
||||
queryParams.value = {
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.bizNo = undefined
|
||||
searchForm.bizType = undefined
|
||||
searchForm.warehouseId = undefined
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10 }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
getList()
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await getWarehouseSimpleList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
238
src/pages-erp/stock/index.vue
Normal file
238
src/pages-erp/stock/index.vue
Normal file
@@ -0,0 +1,238 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="库存查询"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<view @click="searchVisible = true">
|
||||
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 库存列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:产品名称 + 分类 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '-' }}
|
||||
</view>
|
||||
<view class="text-24rpx text-[#999]">
|
||||
{{ item.categoryName || '' }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 单位 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">单位</text>
|
||||
<text>{{ item.unitName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 仓库 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">仓库</text>
|
||||
<text>{{ item.warehouseName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 库存量 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-36rpx text-[#1890ff] font-semibold">{{ formatCount(item.count) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">库存量</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无库存数据" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">产品</view>
|
||||
<wd-picker
|
||||
v-model="searchForm.productId"
|
||||
:columns="productColumns"
|
||||
label=""
|
||||
placeholder="请选择产品"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">仓库</view>
|
||||
<wd-picker
|
||||
v-model="searchForm.warehouseId"
|
||||
:columns="warehouseColumns"
|
||||
label=""
|
||||
placeholder="请选择仓库"
|
||||
@confirm="onWarehouseConfirm"
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">重置</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">搜索</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { Stock } from '@/api/erp/stock'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { getStockPage } from '@/api/erp/stock'
|
||||
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const total = ref(0)
|
||||
const list = ref<Stock[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
productId: undefined as number | undefined,
|
||||
warehouseId: undefined as number | undefined,
|
||||
})
|
||||
|
||||
// 产品和仓库列表
|
||||
const productList = ref<{ id: number, name: string }[]>([])
|
||||
const warehouseList = ref<{ id: number, name: string }[]>([])
|
||||
|
||||
/** 产品下拉列 */
|
||||
const productColumns = computed(() => [
|
||||
[{ value: '', label: '全部' }, ...productList.value.map(v => ({ value: v.id, label: v.name }))],
|
||||
])
|
||||
|
||||
/** 仓库下拉列 */
|
||||
const warehouseColumns = computed(() => [
|
||||
[{ value: '', label: '全部' }, ...warehouseList.value.map(v => ({ value: v.id, label: v.name }))],
|
||||
])
|
||||
|
||||
/** 产品选择回调 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
searchForm.productId = value?.[0] || undefined
|
||||
}
|
||||
|
||||
/** 仓库选择回调 */
|
||||
function onWarehouseConfirm({ value }: any) {
|
||||
searchForm.warehouseId = value?.[0] || undefined
|
||||
}
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.productId) {
|
||||
const product = productList.value.find(p => p.id === searchForm.productId)
|
||||
if (product) conditions.push(`产品:${product.name}`)
|
||||
}
|
||||
if (searchForm.warehouseId) {
|
||||
const warehouse = warehouseList.value.find(w => w.id === searchForm.warehouseId)
|
||||
if (warehouse) conditions.push(`仓库:${warehouse.name}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索库存'
|
||||
})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询库存列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params: Record<string, any> = { ...queryParams.value }
|
||||
if (searchForm.productId) {
|
||||
params.productIds = [searchForm.productId]
|
||||
}
|
||||
if (searchForm.warehouseId) {
|
||||
params.warehouseIds = [searchForm.warehouseId]
|
||||
}
|
||||
const data = await getStockPage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
searchVisible.value = false
|
||||
queryParams.value = {
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.productId = undefined
|
||||
searchForm.warehouseId = undefined
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10 }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
getList()
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await getWarehouseSimpleList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
307
src/pages-erp/supplier/form/index.vue
Normal file
307
src/pages-erp/supplier/form/index.vue
Normal file
@@ -0,0 +1,307 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基础信息" border>
|
||||
<wd-input
|
||||
v-model="formData.name"
|
||||
label="名称"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入供应商名称"
|
||||
prop="name"
|
||||
clearable
|
||||
/>
|
||||
<wd-cell title="企业性质" title-width="180rpx" center>
|
||||
<wd-picker
|
||||
v-model="formData.enterpriseNature"
|
||||
:columns="enterpriseNatureColumns"
|
||||
label=""
|
||||
placeholder="请选择企业性质"
|
||||
@confirm="onEnterpriseNatureConfirm"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="供应商类型" title-width="180rpx" center>
|
||||
<wd-picker
|
||||
v-model="formData.type"
|
||||
:columns="supplierTypeColumns"
|
||||
label=""
|
||||
placeholder="请选择供应商类型"
|
||||
@confirm="onSupplierTypeConfirm"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-input
|
||||
v-model="formData.registeredCapital"
|
||||
label="注册资金"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入注册资金"
|
||||
type="number"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.validPeriod"
|
||||
label="营业期限"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入使用/营业期限"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.zipCode"
|
||||
label="邮编"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入邮编"
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-cell-group title="联系信息" border>
|
||||
<wd-input
|
||||
v-model="formData.contact"
|
||||
label="联系人"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入联系人"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.mobile"
|
||||
label="手机号码"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入手机号码"
|
||||
type="number"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.telephone"
|
||||
label="联系电话"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入联系电话"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.email"
|
||||
label="电子邮箱"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入电子邮箱"
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-cell-group title="财务信息" border>
|
||||
<wd-input
|
||||
v-model="formData.taxNo"
|
||||
label="纳税人识别号"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入纳税人识别号"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.taxPercent"
|
||||
label="税率(%)"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入税率"
|
||||
type="number"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.bankName"
|
||||
label="开户行"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入开户行"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.bankAccount"
|
||||
label="开户账号"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入开户账号"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.bankAddress"
|
||||
label="开户地址"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入开户地址"
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-cell-group title="其他信息" border>
|
||||
<wd-cell title="开启状态" title-width="180rpx" center>
|
||||
<wd-switch v-model="statusEnabled" />
|
||||
</wd-cell>
|
||||
<wd-input
|
||||
v-model="formData.sort"
|
||||
label="排序"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入排序"
|
||||
type="number"
|
||||
clearable
|
||||
/>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { Supplier } from '@/api/erp/supplier'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createSupplier, getSupplier, updateSupplier } from '@/api/erp/supplier'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const toast = useToast()
|
||||
const getTitle = computed(() => props.id ? '编辑供应商' : '新增供应商')
|
||||
const formLoading = ref(false)
|
||||
const formData = ref<Supplier & { enterpriseNature?: string, type?: number, registeredCapital?: number, validPeriod?: string, zipCode?: string }>({
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
contact: undefined,
|
||||
mobile: undefined,
|
||||
telephone: undefined,
|
||||
email: undefined,
|
||||
remark: undefined,
|
||||
status: 0,
|
||||
sort: 0,
|
||||
taxNo: undefined,
|
||||
taxPercent: undefined,
|
||||
bankName: undefined,
|
||||
bankAccount: undefined,
|
||||
bankAddress: undefined,
|
||||
enterpriseNature: undefined,
|
||||
type: undefined,
|
||||
registeredCapital: undefined,
|
||||
validPeriod: undefined,
|
||||
zipCode: undefined,
|
||||
})
|
||||
const formRules = {
|
||||
name: [{ required: true, message: '供应商名称不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 状态开关
|
||||
const statusEnabled = ref(true)
|
||||
watch(statusEnabled, (val) => {
|
||||
formData.value.status = val ? 0 : 1
|
||||
})
|
||||
watch(() => formData.value.status, (val) => {
|
||||
statusEnabled.value = val === 0
|
||||
})
|
||||
|
||||
/** 企业性质选项 */
|
||||
const enterpriseNatureOptions = [
|
||||
{ value: '国有企业', label: '国有企业' },
|
||||
{ value: '集体企业', label: '集体企业' },
|
||||
{ value: '私营企业', label: '私营企业' },
|
||||
{ value: '股份制企业', label: '股份制企业' },
|
||||
{ value: '外资企业', label: '外资企业' },
|
||||
{ value: '合资企业', label: '合资企业' },
|
||||
{ value: '其他', label: '其他' },
|
||||
]
|
||||
const enterpriseNatureColumns = computed(() => [
|
||||
enterpriseNatureOptions.map(v => ({ value: v.value, label: v.label })),
|
||||
])
|
||||
function onEnterpriseNatureConfirm({ value }: any) {
|
||||
formData.value.enterpriseNature = value?.[0]
|
||||
}
|
||||
|
||||
/** 供应商类型选项 */
|
||||
const supplierTypeOptions = [
|
||||
{ value: 1, label: '生产型' },
|
||||
{ value: 2, label: '贸易型' },
|
||||
{ value: 3, label: '服务型' },
|
||||
{ value: 4, label: '其他' },
|
||||
]
|
||||
const supplierTypeColumns = computed(() => [
|
||||
supplierTypeOptions.map(v => ({ value: v.value, label: v.label })),
|
||||
])
|
||||
function onSupplierTypeConfirm({ value }: any) {
|
||||
formData.value.type = value?.[0]
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/supplier/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getSupplier(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
if (props.id) {
|
||||
await updateSupplier(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createSupplier(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
260
src/pages-erp/supplier/index.vue
Normal file
260
src/pages-erp/supplier/index.vue
Normal file
@@ -0,0 +1,260 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="供应商管理"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<view @click="searchVisible = true">
|
||||
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 供应商列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
@click="handleEdit(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:名称 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.name || '-' }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="item.status === 0 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff1f0] text-[#f5222d]'"
|
||||
>
|
||||
{{ item.status === 0 ? '正常' : '停用' }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 联系人 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">联系人</text>
|
||||
<text>{{ item.contact || '-' }}</text>
|
||||
</view>
|
||||
<!-- 手机号码 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">手机号码</text>
|
||||
<text>{{ item.mobile || '-' }}</text>
|
||||
</view>
|
||||
<!-- 联系电话 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">联系电话</text>
|
||||
<text>{{ item.telephone || '-' }}</text>
|
||||
</view>
|
||||
<!-- 电子邮箱 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">电子邮箱</text>
|
||||
<text>{{ item.email || '-' }}</text>
|
||||
</view>
|
||||
<!-- 备注 -->
|
||||
<view class="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.remark || '无备注' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:supplier:update']) && item.name !== '-'"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:supplier:delete']) && item.name !== '-'"
|
||||
size="small" type="error" plain @click="handleDelete(item.id!)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无供应商数据" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 新增按钮 -->
|
||||
<wd-fab
|
||||
v-if="hasAccessByCodes(['erp:supplier:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">供应商名称</view>
|
||||
<wd-input v-model="searchForm.name" placeholder="请输入供应商名称" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">手机号码</view>
|
||||
<wd-input v-model="searchForm.mobile" placeholder="请输入手机号码" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">联系电话</view>
|
||||
<wd-input v-model="searchForm.telephone" placeholder="请输入联系电话" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">重置</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">搜索</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { Supplier } from '@/api/erp/supplier'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteSupplier, getSupplierPage } from '@/api/erp/supplier'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<Supplier[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
name: undefined as string | undefined,
|
||||
mobile: undefined as string | undefined,
|
||||
telephone: undefined as string | undefined,
|
||||
})
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.name) conditions.push(`名称:${searchForm.name}`)
|
||||
if (searchForm.mobile) conditions.push(`手机:${searchForm.mobile}`)
|
||||
if (searchForm.telephone) conditions.push(`电话:${searchForm.telephone}`)
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索供应商'
|
||||
})
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询供应商列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
const data = await getSupplierPage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
searchVisible.value = false
|
||||
queryParams.value = {
|
||||
...searchForm,
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.name = undefined
|
||||
searchForm.mobile = undefined
|
||||
searchForm.telephone = undefined
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10 }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 新增供应商 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/supplier/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: Supplier) {
|
||||
if (item.name === '-') return
|
||||
uni.navigateTo({ url: `/pages-erp/supplier/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该供应商吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteSupplier(id)
|
||||
toast.success('删除成功')
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
187
src/pages-erp/warehouse/form/index.vue
Normal file
187
src/pages-erp/warehouse/form/index.vue
Normal file
@@ -0,0 +1,187 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基础信息" border>
|
||||
<wd-input
|
||||
v-model="formData.name"
|
||||
label="仓库名称"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入仓库名称"
|
||||
prop="name"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.address"
|
||||
label="仓库地址"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入仓库地址"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.principal"
|
||||
label="负责人"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入负责人"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.warehousePrice"
|
||||
label="仓储费"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入仓储费"
|
||||
type="number"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.truckagePrice"
|
||||
label="搬运费"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入搬运费"
|
||||
type="number"
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-cell-group title="状态信息" border>
|
||||
<wd-cell title="仓库状态" title-width="180rpx" center>
|
||||
<wd-switch v-model="statusEnabled" />
|
||||
</wd-cell>
|
||||
<wd-input
|
||||
v-model="formData.sort"
|
||||
label="排序"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入排序"
|
||||
type="number"
|
||||
prop="sort"
|
||||
clearable
|
||||
/>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { Warehouse } from '@/api/erp/warehouse'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createWarehouse, getWarehouse, updateWarehouse } from '@/api/erp/warehouse'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const toast = useToast()
|
||||
const getTitle = computed(() => props.id ? '编辑仓库' : '新增仓库')
|
||||
const formLoading = ref(false)
|
||||
const formData = ref<Warehouse>({
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
address: undefined,
|
||||
principal: undefined,
|
||||
warehousePrice: undefined,
|
||||
truckagePrice: undefined,
|
||||
remark: undefined,
|
||||
status: 0,
|
||||
sort: 0,
|
||||
})
|
||||
const formRules = {
|
||||
name: [{ required: true, message: '仓库名称不能为空' }],
|
||||
sort: [{ required: true, message: '排序不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 状态开关
|
||||
const statusEnabled = ref(true)
|
||||
watch(statusEnabled, (val) => {
|
||||
formData.value.status = val ? 0 : 1
|
||||
})
|
||||
watch(() => formData.value.status, (val) => {
|
||||
statusEnabled.value = val === 0
|
||||
})
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/warehouse/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getWarehouse(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
if (props.id) {
|
||||
await updateWarehouse(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createWarehouse(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
276
src/pages-erp/warehouse/index.vue
Normal file
276
src/pages-erp/warehouse/index.vue
Normal file
@@ -0,0 +1,276 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="仓库管理"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<view @click="searchVisible = true">
|
||||
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 仓库列表 -->
|
||||
<view class="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
@click="handleEdit(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:名称 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.name || '-' }}
|
||||
</view>
|
||||
<view class="flex items-center gap-8rpx">
|
||||
<view
|
||||
v-if="item.defaultStatus"
|
||||
class="rounded-8rpx bg-[#e6f7ff] px-12rpx py-4rpx text-22rpx text-[#1890ff]"
|
||||
>
|
||||
默认
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="item.status === 0 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff1f0] text-[#f5222d]'"
|
||||
>
|
||||
{{ item.status === 0 ? '正常' : '停用' }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 仓库地址 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">仓库地址</text>
|
||||
<text>{{ item.address || '-' }}</text>
|
||||
</view>
|
||||
<!-- 负责人 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">负责人</text>
|
||||
<text>{{ item.principal || '-' }}</text>
|
||||
</view>
|
||||
<!-- 排序 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">排序</text>
|
||||
<text>{{ item.sort ?? '-' }}</text>
|
||||
</view>
|
||||
<!-- 备注 -->
|
||||
<view class="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.remark || '无备注' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:warehouse:update']) && item.name !== '-'"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:warehouse:delete']) && item.name !== '-'"
|
||||
size="small" type="error" plain @click="handleDelete(item.id!)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
|
||||
<wd-status-tip image="content" tip="暂无仓库数据" />
|
||||
</view>
|
||||
<wd-loadmore
|
||||
v-if="list.length > 0"
|
||||
:state="loadMoreState"
|
||||
@reload="loadMore"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 新增按钮 -->
|
||||
<wd-fab
|
||||
v-if="hasAccessByCodes(['erp:warehouse:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
|
||||
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">仓库名称</view>
|
||||
<wd-input v-model="searchForm.name" placeholder="请输入仓库名称" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">仓库状态</view>
|
||||
<view class="yd-search-form-radio-group">
|
||||
<view
|
||||
v-for="opt in statusOptions"
|
||||
:key="opt.value"
|
||||
class="yd-search-form-radio"
|
||||
:class="{ 'yd-search-form-radio--active': searchForm.status === opt.value }"
|
||||
@click="searchForm.status = opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="yd-search-form-actions">
|
||||
<wd-button class="flex-1" plain @click="handleReset">重置</wd-button>
|
||||
<wd-button class="flex-1" type="primary" @click="handleSearch">搜索</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { Warehouse } from '@/api/erp/warehouse'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteWarehouse, getWarehousePage } from '@/api/erp/warehouse'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<Warehouse[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
name: undefined as string | undefined,
|
||||
status: undefined as number | undefined,
|
||||
})
|
||||
|
||||
/** 状态选项 */
|
||||
const statusOptions = [
|
||||
{ value: undefined, label: '全部' },
|
||||
{ value: 0, label: '正常' },
|
||||
{ value: 1, label: '停用' },
|
||||
]
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.name) conditions.push(`名称:${searchForm.name}`)
|
||||
if (searchForm.status !== undefined) {
|
||||
const statusLabel = statusOptions.find(o => o.value === searchForm.status)?.label
|
||||
if (statusLabel && statusLabel !== '全部') conditions.push(`状态:${statusLabel}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索仓库'
|
||||
})
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询仓库列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
const data = await getWarehousePage(params)
|
||||
list.value = [...list.value, ...data.list]
|
||||
total.value = data.total
|
||||
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
|
||||
} catch {
|
||||
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
searchVisible.value = false
|
||||
queryParams.value = {
|
||||
...searchForm,
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.name = undefined
|
||||
searchForm.status = undefined
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10 }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 新增仓库 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/warehouse/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: Warehouse) {
|
||||
if (item.name === '-') return
|
||||
uni.navigateTo({ url: `/pages-erp/warehouse/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该仓库吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteWarehouse(id)
|
||||
toast.success('删除成功')
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
@@ -26,6 +26,168 @@ export interface MenuGroup {
|
||||
|
||||
/** 菜单分组原始数据 */
|
||||
const menuGroupsData: MenuGroup[] = [
|
||||
{
|
||||
key: 'purchase',
|
||||
name: '采购管理',
|
||||
menus: [
|
||||
{
|
||||
key: 'purchaseRequisition',
|
||||
name: '采购申请',
|
||||
icon: 'edit',
|
||||
url: '/pages-erp/purchase-requisition/index',
|
||||
iconColor: '#2f54eb',
|
||||
permission: 'erp:purchase-requisition:query',
|
||||
},
|
||||
{
|
||||
key: 'purchaseOrder',
|
||||
name: '采购订单',
|
||||
icon: 'order',
|
||||
url: '/pages-erp/purchase-order/index',
|
||||
iconColor: '#1890ff',
|
||||
permission: 'erp:purchase-order:query',
|
||||
},
|
||||
{
|
||||
key: 'purchaseIn',
|
||||
name: '采购入库',
|
||||
icon: 'goods',
|
||||
url: '/pages-erp/purchase-in/index',
|
||||
iconColor: '#52c41a',
|
||||
permission: 'erp:purchase-in:query',
|
||||
},
|
||||
{
|
||||
key: 'purchaseReturn',
|
||||
name: '采购退货',
|
||||
icon: 'refund',
|
||||
url: '/pages-erp/purchase-return/index',
|
||||
iconColor: '#fa8c16',
|
||||
permission: 'erp:purchase-return:query',
|
||||
},
|
||||
{
|
||||
key: 'supplier',
|
||||
name: '供应商',
|
||||
icon: 'shop',
|
||||
url: '/pages-erp/supplier/index',
|
||||
iconColor: '#722ed1',
|
||||
permission: 'erp:supplier:query',
|
||||
},
|
||||
{
|
||||
key: 'farmer',
|
||||
name: '农户管理',
|
||||
icon: 'user',
|
||||
url: '/pages-erp/farmer/index',
|
||||
iconColor: '#13c2c2',
|
||||
permission: 'erp:farmer:query',
|
||||
},
|
||||
{
|
||||
key: 'pickBroccoli',
|
||||
name: '采摘管理',
|
||||
icon: 'flower',
|
||||
url: '/pages-erp/pick-broccoli/index',
|
||||
iconColor: '#eb2f96',
|
||||
permission: 'erp:pick-broccoli:query',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'agri',
|
||||
name: '农业溯源',
|
||||
menus: [
|
||||
{
|
||||
key: 'agriBizFlow',
|
||||
name: '闭环操作台',
|
||||
icon: 'flow',
|
||||
url: '/pages-agri/biz-flow/index',
|
||||
iconColor: '#52c41a',
|
||||
permission: 'agri:biz:harvest',
|
||||
},
|
||||
{
|
||||
key: 'agriTraceSnapshot',
|
||||
name: '溯源快照',
|
||||
icon: 'scan',
|
||||
url: '/pages-agri/trace-snapshot/index',
|
||||
iconColor: '#1890ff',
|
||||
permission: 'agri:trace-snapshot:query',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'stock',
|
||||
name: '库存管理',
|
||||
menus: [
|
||||
{
|
||||
key: 'warehouse',
|
||||
name: '仓库管理',
|
||||
icon: 'shop',
|
||||
url: '/pages-erp/warehouse/index',
|
||||
iconColor: '#1890ff',
|
||||
permission: 'erp:warehouse:query',
|
||||
},
|
||||
{
|
||||
key: 'stock',
|
||||
name: '库存查询',
|
||||
icon: 'goods',
|
||||
url: '/pages-erp/stock/index',
|
||||
iconColor: '#52c41a',
|
||||
permission: 'erp:stock:query',
|
||||
},
|
||||
{
|
||||
key: 'stockRecord',
|
||||
name: '库存记录',
|
||||
icon: 'history',
|
||||
url: '/pages-erp/stock-record/index',
|
||||
iconColor: '#722ed1',
|
||||
permission: 'erp:stock-record:query',
|
||||
},
|
||||
{
|
||||
key: 'stockIn',
|
||||
name: '其他入库',
|
||||
icon: 'add-circle',
|
||||
url: '/pages-erp/stock-in/index',
|
||||
iconColor: '#13c2c2',
|
||||
permission: 'erp:stock-in:query',
|
||||
},
|
||||
{
|
||||
key: 'stockOut',
|
||||
name: '其他出库',
|
||||
icon: 'arrow-right',
|
||||
url: '/pages-erp/stock-out/index',
|
||||
iconColor: '#fa8c16',
|
||||
permission: 'erp:stock-out:query',
|
||||
},
|
||||
{
|
||||
key: 'stockGain',
|
||||
name: '库存报溢',
|
||||
icon: 'add',
|
||||
url: '/pages-erp/stock-gain/index',
|
||||
iconColor: '#52c41a',
|
||||
permission: 'erp:stock-gain:query',
|
||||
},
|
||||
{
|
||||
key: 'stockLoss',
|
||||
name: '库存报损',
|
||||
icon: 'close',
|
||||
url: '/pages-erp/stock-loss/index',
|
||||
iconColor: '#f5222d',
|
||||
permission: 'erp:stock-loss:query',
|
||||
},
|
||||
{
|
||||
key: 'stockCheck',
|
||||
name: '库存盘点',
|
||||
icon: 'check',
|
||||
url: '/pages-erp/stock-check/index',
|
||||
iconColor: '#722ed1',
|
||||
permission: 'erp:stock-check:query',
|
||||
},
|
||||
{
|
||||
key: 'stockMove',
|
||||
name: '库存调拨',
|
||||
icon: 'transfer',
|
||||
url: '/pages-erp/stock-move/index',
|
||||
iconColor: '#eb2f96',
|
||||
permission: 'erp:stock-move:query',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'system',
|
||||
name: '系统管理',
|
||||
|
||||
18
src/utils/agriTraceDict.ts
Normal file
18
src/utils/agriTraceDict.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export const BATCH_TYPE_LABEL_MAP: Record<string, string> = {
|
||||
HARVEST: '采收批次',
|
||||
SORTING: '分拣批次',
|
||||
PACKING: '装箱批次',
|
||||
WAREHOUSE: '仓储批次',
|
||||
SHIPMENT: '发运批次'
|
||||
}
|
||||
|
||||
export const IN_MODE_LABEL_MAP: Record<string, string> = {
|
||||
BOX: '按箱入库',
|
||||
PALLET: '按托入库'
|
||||
}
|
||||
|
||||
const toOptions = (labelMap: Record<string, string>) =>
|
||||
Object.entries(labelMap).map(([value, label]) => ({ label, value }))
|
||||
|
||||
export const BATCH_TYPE_OPTIONS = toOptions(BATCH_TYPE_LABEL_MAP)
|
||||
export const IN_MODE_OPTIONS = toOptions(IN_MODE_LABEL_MAP)
|
||||
@@ -124,7 +124,7 @@ export function getEnvBaseUrl() {
|
||||
// # 有些同学可能需要在微信小程序里面根据 develop、trial、release 分别设置上传地址,参考代码如下。
|
||||
// TODO @芋艿:这个后续也要调整。
|
||||
const VITE_SERVER_BASEURL__WEIXIN_DEVELOP = 'http://localhost:48080/admin-api'
|
||||
const VITE_SERVER_BASEURL__WEIXIN_TRIAL = 'http://localhost:48080/admin-api'
|
||||
const VITE_SERVER_BASEURL__WEIXIN_TRIAL = 'http://119.96.62.56:7004/admin-api'
|
||||
const VITE_SERVER_BASEURL__WEIXIN_RELEASE = 'http://localhost:48080/admin-api'
|
||||
|
||||
// 微信小程序端环境区分
|
||||
|
||||
@@ -77,6 +77,8 @@ export default defineConfig(({ command, mode }) => {
|
||||
'src/pages-system', // “系统管理”模块
|
||||
'src/pages-infra', // “基础设施”模块
|
||||
'src/pages-bpm', // “工作流程”模块
|
||||
'src/pages-erp', // “采购管理”模块
|
||||
'src/pages-agri', // “农业溯源”模块
|
||||
],
|
||||
dts: 'src/types/uni-pages.d.ts',
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user