李红攀:V2.0.001仓库管理
This commit is contained in:
121
src/api/erp/purchase-requisition/index.ts
Normal file
121
src/api/erp/purchase-requisition/index.ts
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
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
|
||||||
|
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
|
||||||
|
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: '特急' },
|
||||||
|
]
|
||||||
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)
|
||||||
|
}
|
||||||
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')
|
||||||
|
}
|
||||||
360
src/pages-erp/purchase-requisition/detail/index.vue
Normal file
360
src/pages-erp/purchase-requisition/detail/index.vue
Normal file
@@ -0,0 +1,360 @@
|
|||||||
|
<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.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-[#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>
|
||||||
474
src/pages-erp/purchase-requisition/form/index.vue
Normal file
474
src/pages-erp/purchase-requisition/form/index.vue
Normal file
@@ -0,0 +1,474 @@
|
|||||||
|
<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-[#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(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 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,
|
||||||
|
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
|
||||||
|
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.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 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>
|
||||||
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>
|
||||||
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>
|
||||||
@@ -30,6 +30,14 @@ const menuGroupsData: MenuGroup[] = [
|
|||||||
key: 'purchase',
|
key: 'purchase',
|
||||||
name: '采购管理',
|
name: '采购管理',
|
||||||
menus: [
|
menus: [
|
||||||
|
{
|
||||||
|
key: 'purchaseRequisition',
|
||||||
|
name: '采购申请',
|
||||||
|
icon: 'edit',
|
||||||
|
url: '/pages-erp/purchase-requisition/index',
|
||||||
|
iconColor: '#2f54eb',
|
||||||
|
permission: 'erp:purchase-requisition:query',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'purchaseOrder',
|
key: 'purchaseOrder',
|
||||||
name: '采购订单',
|
name: '采购订单',
|
||||||
@@ -80,6 +88,84 @@ const menuGroupsData: MenuGroup[] = [
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
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',
|
key: 'system',
|
||||||
name: '系统管理',
|
name: '系统管理',
|
||||||
|
|||||||
Reference in New Issue
Block a user