feat(wms):优化整体代码结构

wms
YunaiV 2026-05-15 12:59:11 +08:00
parent 24343f66fc
commit f82ae7e0c8
23 changed files with 414 additions and 282 deletions

View File

@ -63,7 +63,9 @@ const goodsShareList = ref<ChartItem[]>([])
const inventoryDistributionList = ref<ChartItem[]>([])
/** 格式化库存数量展示 */
const formatQuantityText = (value: number) => formatQuantity(value) || '0.00'
function formatQuantityText(value: number) {
return formatQuantity(value) || '0.00'
}
const chartFontFamily =
"Inter, 'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif"

View File

@ -213,7 +213,9 @@ const getStatusPercent = (item: OrderSummaryItem, status: number) => {
}
/** 格式化单据数量 */
const formatCount = (value: number) => value.toLocaleString()
function formatCount(value: number) {
return value.toLocaleString()
}
defineExpose({ load })
</script>

View File

@ -148,14 +148,18 @@ const total = ref(0) // 列表的总条数
const selectedMap = ref<Map<string, InventorySelectRow>>(new Map()) //
const tableRef = ref<InstanceType<typeof ElTable>>() // Ref
const queryFormRef = ref() //
const getDefaultQueryParams = () => ({
pageNo: 1,
pageSize: 10,
itemName: undefined as string | undefined,
itemCode: undefined as string | undefined,
skuName: undefined as string | undefined,
skuCode: undefined as string | undefined
})
/** 获得默认的查询参数 */
function getDefaultQueryParams() {
return {
pageNo: 1,
pageSize: 10,
itemName: undefined as string | undefined,
itemCode: undefined as string | undefined,
skuName: undefined as string | undefined,
skuCode: undefined as string | undefined
}
}
const queryParams = reactive(getDefaultQueryParams())
const emit = defineEmits<{

View File

@ -236,19 +236,21 @@ const open = async (type: string, id?: number) => {
defineExpose({ open }) // open
/** 构建空规格 */
const buildEmptySku = (): ItemSkuVO => ({
id: undefined,
name: undefined,
barCode: undefined,
code: undefined,
length: undefined,
width: undefined,
height: undefined,
grossWeight: undefined,
netWeight: undefined,
costPrice: undefined,
sellingPrice: undefined
})
function buildEmptySku(): ItemSkuVO {
return {
id: undefined,
name: undefined,
barCode: undefined,
code: undefined,
length: undefined,
width: undefined,
height: undefined,
grossWeight: undefined,
netWeight: undefined,
costPrice: undefined,
sellingPrice: undefined
}
}
/** 添加规格 */
const handleAddSku = () => {

View File

@ -122,9 +122,13 @@ const getTree = async () => {
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
if (!formRef) return
if (!formRef) {
return
}
const valid = await formRef.value.validate()
if (!valid) return
if (!valid) {
return
}
//
formLoading.value = true
try {

View File

@ -104,20 +104,20 @@
</el-table-column>
<el-table-column label="金额(元)" min-width="140">
<template #default="scope">
<div v-if="hasValue(scope.row.costPrice)">
<div v-if="!isNullOrUnDef(scope.row.costPrice)">
成本价{{ formatPrice(scope.row.costPrice) }}
</div>
<div v-if="hasValue(scope.row.sellingPrice)">
<div v-if="!isNullOrUnDef(scope.row.sellingPrice)">
销售价{{ formatPrice(scope.row.sellingPrice) }}
</div>
</template>
</el-table-column>
<el-table-column label="重量(kg)" min-width="140">
<template #default="scope">
<div v-if="hasValue(scope.row.netWeight)">
<div v-if="!isNullOrUnDef(scope.row.netWeight)">
净重{{ formatWeight(scope.row.netWeight) }}
</div>
<div v-if="hasValue(scope.row.grossWeight)">
<div v-if="!isNullOrUnDef(scope.row.grossWeight)">
毛重{{ formatWeight(scope.row.grossWeight) }}
</div>
</template>
@ -200,7 +200,6 @@ const queryParams = reactive<{
const queryFormRef = ref() //
const categoryTreeRef = ref() //
const exportLoading = ref(false) //
const hasValue = (value?: number | string | null) => !isNullOrUnDef(value)
/** 查询商品列表 */
const getList = async () => {

View File

@ -173,15 +173,19 @@ const preselectDisabled = ref(true) // 是否回显已禁用的 SKU
const syncingSingleSelection = ref(false) //
const tableRef = ref<InstanceType<typeof ElTable>>() // Ref
const queryFormRef = ref() //
const getDefaultQueryParams = () => ({
pageNo: 1,
pageSize: 10,
itemName: undefined as string | undefined,
itemCode: undefined as string | undefined,
name: undefined as string | undefined,
code: undefined as string | undefined,
barCode: undefined as string | undefined
})
/** 获得默认的查询参数 */
function getDefaultQueryParams() {
return {
pageNo: 1,
pageSize: 10,
itemName: undefined as string | undefined,
itemCode: undefined as string | undefined,
name: undefined as string | undefined,
code: undefined as string | undefined,
barCode: undefined as string | undefined
}
}
const queryParams = reactive(getDefaultQueryParams())
const emit = defineEmits<{

View File

@ -124,11 +124,16 @@ defineOptions({ name: 'WmsCheckOrderDetail' })
const loading = ref(false)
const dialogVisible = ref(false)
const detailData = ref<CheckOrderVO>({})
const getOrderDifferencePrice = (order: CheckOrderVO) =>
roundPrice(Number(order.actualPrice || 0) - Number(order.totalPrice || 0))
const getDifferenceQuantity = (detail: CheckOrderDetailVO) =>
Number(detail.checkQuantity || 0) - Number(detail.quantity || 0)
const getActualPrice = (detail: CheckOrderDetailVO) => {
function getOrderDifferencePrice(order: CheckOrderVO) {
return roundPrice(Number(order.actualPrice || 0) - Number(order.totalPrice || 0))
}
function getDifferenceQuantity(detail: CheckOrderDetailVO) {
return Number(detail.checkQuantity || 0) - Number(detail.quantity || 0)
}
function getActualPrice(detail: CheckOrderDetailVO) {
if (
detail.checkQuantity === undefined ||
detail.checkQuantity === null ||
@ -139,19 +144,22 @@ const getActualPrice = (detail: CheckOrderDetailVO) => {
}
return roundPrice(Number(detail.checkQuantity) * Number(detail.price))
}
const getDifferencePrice = (detail: CheckOrderDetailVO) => {
function getDifferencePrice(detail: CheckOrderDetailVO) {
if (detail.price === undefined || detail.price === null) {
return undefined
}
return roundPrice(getDifferenceQuantity(detail) * Number(detail.price))
}
const renderLossText = (
function renderLossText(
value: number | string | null | undefined,
formatter: (value?: number | string | null) => string
) => h('span', { class: getLossClass(value) }, formatter(value))
) {
return h('span', { class: getLossClass(value) }, formatter(value))
}
const getSummaries = ({ columns, data }: { columns: any[]; data: CheckOrderDetailVO[] }) =>
columns.map((column, index) => {
/** 计算表格的合计行数据 */
function getSummaries({ columns, data }: { columns: any[]; data: CheckOrderDetailVO[] }) {
return columns.map((column, index) => {
if (index === 0) {
return '合计'
}
@ -178,6 +186,7 @@ const getSummaries = ({ columns, data }: { columns: any[]; data: CheckOrderDetai
}
return ''
})
}
/** 打开弹窗 */
const open = async (id: number) => {

View File

@ -284,21 +284,31 @@ const warehouseFormRules = reactive<FormRules>({
warehouseId: [{ required: true, message: '仓库不能为空', trigger: 'change' }]
})
const getDifferenceQuantity = (detail: CheckOrderFormDetail) =>
Number(detail.checkQuantity || 0) - Number(detail.quantity || 0)
const getBookPrice = (detail: CheckOrderFormDetail) => multiplyPrice(detail.quantity, detail.price)
const getActualPrice = (detail: CheckOrderFormDetail) =>
detail.actualPrice ?? multiplyPrice(detail.checkQuantity, detail.price)
const getDifferencePrice = (detail: CheckOrderFormDetail) => {
function getDifferenceQuantity(detail: CheckOrderFormDetail) {
return Number(detail.checkQuantity || 0) - Number(detail.quantity || 0)
}
function getBookPrice(detail: CheckOrderFormDetail) {
return multiplyPrice(detail.quantity, detail.price)
}
function getActualPrice(detail: CheckOrderFormDetail) {
return detail.actualPrice ?? multiplyPrice(detail.checkQuantity, detail.price)
}
function getDifferencePrice(detail: CheckOrderFormDetail) {
if (detail.price === undefined || detail.price === null) {
return undefined
}
return roundPrice(getDifferenceQuantity(detail) * Number(detail.price))
}
const renderLossText = (
function renderLossText(
value: number | string | null | undefined,
formatter: (value?: number | string | null) => string
) => h('span', { class: getLossClass(value) }, formatter(value))
) {
return h('span', { class: getLossClass(value) }, formatter(value))
}
const totalQuantity = computed(() =>
sumQuantity(formData.value.details || [], (detail) => getDifferenceQuantity(detail))
)
@ -369,30 +379,33 @@ const handleWarehouseSelect = (warehouse: WarehouseVO | undefined) => {
}
/** 构建盘库明细 */
const buildDetail = (inventory: CheckInventoryRow): CheckOrderFormDetail => ({
id: undefined,
itemId: inventory.itemId,
itemCode: inventory.itemCode,
itemName: inventory.itemName,
unit: inventory.unit,
skuId: inventory.skuId,
skuCode: inventory.skuCode,
skuName: inventory.skuName,
inventoryId: inventory.id,
warehouseId: inventory.warehouseId,
warehouseName: inventory.warehouseName,
quantity: inventory.availableQuantity,
checkQuantity: inventory.availableQuantity,
availableQuantity: inventory.availableQuantity,
price: inventory.price,
actualPrice: multiplyPrice(inventory.availableQuantity, inventory.price)
})
function buildDetail(inventory: CheckInventoryRow): CheckOrderFormDetail {
return {
id: undefined,
itemId: inventory.itemId,
itemCode: inventory.itemCode,
itemName: inventory.itemName,
unit: inventory.unit,
skuId: inventory.skuId,
skuCode: inventory.skuCode,
skuName: inventory.skuName,
inventoryId: inventory.id,
warehouseId: inventory.warehouseId,
warehouseName: inventory.warehouseName,
quantity: inventory.availableQuantity,
checkQuantity: inventory.availableQuantity,
availableQuantity: inventory.availableQuantity,
price: inventory.price,
actualPrice: multiplyPrice(inventory.availableQuantity, inventory.price)
}
}
const normalizeDetails = (details: CheckOrderDetailVO[]) =>
details.map((detail) => ({
function normalizeDetails(details: CheckOrderDetailVO[]) {
return details.map((detail) => ({
...detail,
actualPrice: multiplyPrice(detail.checkQuantity, detail.price)
}))
}
/** 导入当前仓库的全部库存余额 */
const handleImportAllInventory = async () => {
@ -473,24 +486,26 @@ const getWarehouseInventoryMap = async (): Promise<Map<number, InventoryVO>> =>
}
/** 构建零库存盘库明细 */
const buildZeroInventoryDetail = (sku: ItemSkuVO): CheckOrderFormDetail => ({
id: undefined,
itemId: sku.itemId,
itemCode: sku.itemCode,
itemName: sku.itemName,
unit: sku.unit,
skuId: sku.id,
skuCode: sku.code,
skuName: sku.name,
inventoryId: undefined,
warehouseId: formData.value.warehouseId,
warehouseName: formData.value.warehouseName,
quantity: 0,
checkQuantity: 0,
availableQuantity: 0,
price: sku.costPrice,
actualPrice: 0
})
function buildZeroInventoryDetail(sku: ItemSkuVO): CheckOrderFormDetail {
return {
id: undefined,
itemId: sku.itemId,
itemCode: sku.itemCode,
itemName: sku.itemName,
unit: sku.unit,
skuId: sku.id,
skuCode: sku.code,
skuName: sku.name,
inventoryId: undefined,
warehouseId: formData.value.warehouseId,
warehouseName: formData.value.warehouseName,
quantity: 0,
checkQuantity: 0,
availableQuantity: 0,
price: sku.costPrice,
actualPrice: 0
}
}
const handleDeleteDetail = (index: number) => {
formData.value.details?.splice(index, 1)
@ -512,20 +527,30 @@ const handleDetailActualPriceChange = (detail: CheckOrderFormDetail) => {
detail.price = dividePrice(detail.actualPrice, detail.checkQuantity)
}
const getDetailSummaries = ({ columns, data }: { columns: any[]; data: CheckOrderFormDetail[] }) =>
columns.map((column, index) => {
if (index === 0) return '合计'
if (column.property === 'quantity') return formatSumQuantity(data, (detail) => detail.quantity)
if (column.property === 'checkQuantity')
/** 计算表格的合计行数据 */
function getDetailSummaries({ columns, data }: { columns: any[]; data: CheckOrderFormDetail[] }) {
return columns.map((column, index) => {
if (index === 0) {
return '合计'
}
if (column.property === 'quantity') {
return formatSumQuantity(data, (detail) => detail.quantity)
}
if (column.property === 'checkQuantity') {
return formatSumQuantity(data, (detail) => detail.checkQuantity)
if (column.property === 'actualPrice')
}
if (column.property === 'actualPrice') {
return formatSumPrice(data, (detail) => getActualPrice(detail))
if (column.property === 'differenceQuantity')
}
if (column.property === 'differenceQuantity') {
return renderLossText(totalQuantity.value, formatQuantity)
if (column.property === 'differencePrice')
}
if (column.property === 'differencePrice') {
return renderLossText(differencePrice.value, formatPrice)
}
return ''
})
}
/** 校验明细 */
const validateDetails = (required: boolean) => {
@ -566,7 +591,9 @@ const buildSubmitData = () => {
const emit = defineEmits(['success'])
const submitForm = async () => {
await formRef.value.validate()
if (!validateDetails(false)) return
if (!validateDetails(false)) {
return
}
formLoading.value = true
try {
const data = buildSubmitData()
@ -587,7 +614,9 @@ const submitForm = async () => {
/** 完成盘库:表单修改过则先保存,再完成 */
const handleComplete = async () => {
await formRef.value.validate()
if (!validateDetails(true)) return
if (!validateDetails(true)) {
return
}
try {
await message.confirm('确认完成盘库?完成后将更新库存。')
formLoading.value = true

View File

@ -149,9 +149,11 @@ interface PrintRow extends CheckOrderDetailVO {
differencePrice?: number
}
const getDifferenceQuantity = (detail: CheckOrderDetailVO) =>
Number(detail.checkQuantity || 0) - Number(detail.quantity || 0)
const getActualPrice = (detail: CheckOrderDetailVO) => {
function getDifferenceQuantity(detail: CheckOrderDetailVO) {
return Number(detail.checkQuantity || 0) - Number(detail.quantity || 0)
}
function getActualPrice(detail: CheckOrderDetailVO) {
if (
detail.checkQuantity === undefined ||
detail.checkQuantity === null ||
@ -162,14 +164,15 @@ const getActualPrice = (detail: CheckOrderDetailVO) => {
}
return roundPrice(Number(detail.checkQuantity) * Number(detail.price))
}
const getDifferencePrice = (detail: CheckOrderDetailVO, differenceQuantity: number) => {
function getDifferencePrice(detail: CheckOrderDetailVO, differenceQuantity: number) {
if (detail.price === undefined || detail.price === null) {
return undefined
}
return roundPrice(differenceQuantity * Number(detail.price))
}
const getOrderDifferencePrice = (order: CheckOrderVO) =>
roundPrice(Number(order.actualPrice || 0) - Number(order.totalPrice || 0))
function getOrderDifferencePrice(order: CheckOrderVO) {
return roundPrice(Number(order.actualPrice || 0) - Number(order.totalPrice || 0))
}
const printRows = computed<PrintRow[]>(() =>
(printData.value.details || []).map((detail) => {
const differenceQuantity = getDifferenceQuantity(detail)

View File

@ -436,34 +436,42 @@ const checkedTableColumns = ref<TableColumnKey[]>([
'operateInfo',
'remark'
])
const isTableColumnVisible = (column: TableColumnKey) => checkedTableColumns.value.includes(column)
const loading = ref(true) //
const list = ref<CheckOrderVO[]>([]) //
const total = ref(0) //
const getDefaultQueryParams = () => ({
pageNo: 1,
pageSize: 10,
no: undefined as string | undefined,
status: undefined as number | undefined,
warehouseId: undefined as number | undefined,
orderTime: undefined as string[] | undefined,
totalQuantityMin: undefined as number | undefined,
totalQuantityMax: undefined as number | undefined,
totalPriceMin: undefined as number | undefined,
totalPriceMax: undefined as number | undefined,
actualPriceMin: undefined as number | undefined,
actualPriceMax: undefined as number | undefined,
creator: undefined as number | undefined,
updater: undefined as number | undefined,
createTime: undefined as string[] | undefined,
updateTime: undefined as string[] | undefined
})
/** 获得默认的查询参数 */
function getDefaultQueryParams() {
return {
pageNo: 1,
pageSize: 10,
no: undefined as string | undefined,
status: undefined as number | undefined,
warehouseId: undefined as number | undefined,
orderTime: undefined as string[] | undefined,
totalQuantityMin: undefined as number | undefined,
totalQuantityMax: undefined as number | undefined,
totalPriceMin: undefined as number | undefined,
totalPriceMax: undefined as number | undefined,
actualPriceMin: undefined as number | undefined,
actualPriceMax: undefined as number | undefined,
creator: undefined as number | undefined,
updater: undefined as number | undefined,
createTime: undefined as string[] | undefined,
updateTime: undefined as string[] | undefined
}
}
const queryParams = reactive(getDefaultQueryParams())
const queryFormRef = ref() //
const exportLoading = ref(false) //
const detailMap = reactive<Record<number, CheckOrderDetailVO[]>>({}) //
/** 判断表格列是否可见 */
function isTableColumnVisible(column: TableColumnKey) {
return checkedTableColumns.value.includes(column)
}
/** 是否允许修改盘库单 */
const canUpdateCheckOrder = (status?: number) => {
return status !== undefined && OrderUpdateStatusList.includes(status)

View File

@ -110,14 +110,24 @@ const detailRows = computed<DetailRow[]>(() =>
}))
)
const getSummaries = ({ columns, data }: { columns: any[]; data: DetailRow[] }) =>
columns.map((column, index) => {
if (index === 0) return '合计'
if (column.property === 'quantity') return formatSumQuantity(data, (detail) => detail.quantity)
if (column.property === 'price') return formatSumPrice(data, (detail) => detail.price)
if (column.property === 'totalPrice') return formatSumPrice(data, (detail) => detail.totalPrice)
/** 计算表格的合计行数据 */
function getSummaries({ columns, data }: { columns: any[]; data: DetailRow[] }) {
return columns.map((column, index) => {
if (index === 0) {
return '合计'
}
if (column.property === 'quantity') {
return formatSumQuantity(data, (detail) => detail.quantity)
}
if (column.property === 'price') {
return formatSumPrice(data, (detail) => detail.price)
}
if (column.property === 'totalPrice') {
return formatSumPrice(data, (detail) => detail.totalPrice)
}
return ''
})
}
/** 打开弹窗 */
const open = async (id: number) => {

View File

@ -279,29 +279,32 @@ const open = async (type: string, id?: number) => {
defineExpose({ open })
/** 构建移库明细 */
const buildDetail = (inventory: InventorySelectRow): MovementOrderDetailVO => ({
id: undefined,
itemId: inventory.itemId,
itemCode: inventory.itemCode,
itemName: inventory.itemName,
unit: inventory.unit,
skuId: inventory.skuId,
skuCode: inventory.skuCode,
skuName: inventory.skuName,
sourceWarehouseId: inventory.warehouseId,
sourceWarehouseName: inventory.warehouseName,
targetWarehouseId: formData.value.targetWarehouseId,
quantity: undefined,
availableQuantity: inventory.availableQuantity,
price: undefined,
totalPrice: undefined
})
function buildDetail(inventory: InventorySelectRow): MovementOrderDetailVO {
return {
id: undefined,
itemId: inventory.itemId,
itemCode: inventory.itemCode,
itemName: inventory.itemName,
unit: inventory.unit,
skuId: inventory.skuId,
skuCode: inventory.skuCode,
skuName: inventory.skuName,
sourceWarehouseId: inventory.warehouseId,
sourceWarehouseName: inventory.warehouseName,
targetWarehouseId: formData.value.targetWarehouseId,
quantity: undefined,
availableQuantity: inventory.availableQuantity,
price: undefined,
totalPrice: undefined
}
}
const normalizeDetails = (details: MovementOrderDetailVO[]) =>
details.map((detail) => ({
function normalizeDetails(details: MovementOrderDetailVO[]) {
return details.map((detail) => ({
...detail,
totalPrice: detail.totalPrice ?? multiplyPrice(detail.quantity, detail.price)
}))
}
/** 打开库存选择弹窗 */
const handleAddDetail = () => {
@ -313,19 +316,24 @@ const handleAddDetail = () => {
/** 选择库存 */
const handleSelectInventory = (inventories: InventorySelectRow[]) => {
if (!inventories.length) return
if (!inventories.length) {
return
}
formData.value.details = formData.value.details || []
inventories.forEach((inventory) => {
if (isInventorySelected(inventory)) return
if (isInventorySelected(inventory)) {
return
}
formData.value.details!.push(buildDetail(inventory))
})
}
/** 判断库存是否已选择 */
const isInventorySelected = (inventory: InventorySelectRow) =>
(formData.value.details || []).some((detail) => {
function isInventorySelected(inventory: InventorySelectRow) {
return (formData.value.details || []).some((detail) => {
return detail.skuId === inventory.skuId && detail.sourceWarehouseId === inventory.warehouseId
})
}
const handleDeleteDetail = (index: number) => {
formData.value.details?.splice(index, 1)
@ -360,8 +368,15 @@ const handleDetailTotalPriceChange = (detail: MovementOrderDetailVO) => {
detail.price = dividePrice(detail.totalPrice, detail.quantity)
}
const getDetailSummaries = ({ columns, data }: { columns: any[]; data: MovementOrderDetailVO[] }) =>
columns.map((column, index) => {
/** 计算表格的合计行数据 */
function getDetailSummaries({
columns,
data
}: {
columns: any[]
data: MovementOrderDetailVO[]
}) {
return columns.map((column, index) => {
if (index === 0) {
return '合计'
}
@ -376,6 +391,7 @@ const getDetailSummaries = ({ columns, data }: { columns: any[]; data: MovementO
}
return ''
})
}
/** 校验明细 */
const validateDetails = (required: boolean) => {
@ -421,7 +437,9 @@ const buildSubmitData = () => {
const emit = defineEmits(['success'])
const submitForm = async () => {
await formRef.value.validate()
if (!validateDetails(false)) return
if (!validateDetails(false)) {
return
}
formLoading.value = true
try {
const data = buildSubmitData()
@ -442,7 +460,9 @@ const submitForm = async () => {
/** 完成移库:表单修改过则先保存,再完成 */
const handleComplete = async () => {
await formRef.value.validate()
if (!validateDetails(true)) return
if (!validateDetails(true)) {
return
}
try {
await message.confirm('确认完成移库?完成后将更新库存。')
formLoading.value = true

View File

@ -399,33 +399,41 @@ const checkedTableColumns = ref<TableColumnKey[]>([
'operateInfo',
'remark'
])
const isTableColumnVisible = (column: TableColumnKey) => checkedTableColumns.value.includes(column)
const loading = ref(true) //
const list = ref<MovementOrderVO[]>([]) //
const total = ref(0) //
const getDefaultQueryParams = () => ({
pageNo: 1,
pageSize: 10,
no: undefined as string | undefined,
status: undefined as number | undefined,
sourceWarehouseId: undefined as number | undefined,
targetWarehouseId: undefined as number | undefined,
orderTime: undefined as string[] | undefined,
totalQuantityMin: undefined as number | undefined,
totalQuantityMax: undefined as number | undefined,
totalPriceMin: undefined as number | undefined,
totalPriceMax: undefined as number | undefined,
creator: undefined as number | undefined,
updater: undefined as number | undefined,
createTime: undefined as string[] | undefined,
updateTime: undefined as string[] | undefined
})
/** 获得默认的查询参数 */
function getDefaultQueryParams() {
return {
pageNo: 1,
pageSize: 10,
no: undefined as string | undefined,
status: undefined as number | undefined,
sourceWarehouseId: undefined as number | undefined,
targetWarehouseId: undefined as number | undefined,
orderTime: undefined as string[] | undefined,
totalQuantityMin: undefined as number | undefined,
totalQuantityMax: undefined as number | undefined,
totalPriceMin: undefined as number | undefined,
totalPriceMax: undefined as number | undefined,
creator: undefined as number | undefined,
updater: undefined as number | undefined,
createTime: undefined as string[] | undefined,
updateTime: undefined as string[] | undefined
}
}
const queryParams = reactive(getDefaultQueryParams())
const queryFormRef = ref() //
const exportLoading = ref(false) //
const detailMap = reactive<Record<number, MovementOrderDetailVO[]>>({}) //
/** 判断表格列是否可见 */
function isTableColumnVisible(column: TableColumnKey) {
return checkedTableColumns.value.includes(column)
}
/** 是否允许修改移库单 */
const canUpdateMovementOrder = (status?: number) => {
return status !== undefined && OrderUpdateStatusList.includes(status)

View File

@ -127,8 +127,9 @@ const detailRows = computed<DetailRow[]>(() =>
}))
)
const getSummaries = ({ columns, data }: { columns: any[]; data: DetailRow[] }) =>
columns.map((column, index) => {
/** 计算表格的合计行数据 */
function getSummaries({ columns, data }: { columns: any[]; data: DetailRow[] }) {
return columns.map((column, index) => {
if (index === 0) {
return '合计'
}
@ -143,6 +144,7 @@ const getSummaries = ({ columns, data }: { columns: any[]; data: DetailRow[] })
}
return ''
})
}
/** 打开弹窗 */
const open = async (id: number) => {

View File

@ -282,25 +282,28 @@ const open = async (type: string, id?: number) => {
defineExpose({ open }) // open
/** 构建入库明细 */
const buildDetail = (sku: ItemSkuVO): ReceiptOrderDetailVO => ({
id: undefined,
itemId: sku.itemId,
itemCode: sku.itemCode,
itemName: sku.itemName,
unit: sku.unit,
skuId: sku.id,
skuCode: sku.code,
skuName: sku.name,
quantity: undefined,
price: undefined,
totalPrice: undefined
})
function buildDetail(sku: ItemSkuVO): ReceiptOrderDetailVO {
return {
id: undefined,
itemId: sku.itemId,
itemCode: sku.itemCode,
itemName: sku.itemName,
unit: sku.unit,
skuId: sku.id,
skuCode: sku.code,
skuName: sku.name,
quantity: undefined,
price: undefined,
totalPrice: undefined
}
}
const normalizeDetails = (details: ReceiptOrderDetailVO[]) =>
details.map((detail) => ({
function normalizeDetails(details: ReceiptOrderDetailVO[]) {
return details.map((detail) => ({
...detail,
totalPrice: detail.totalPrice ?? multiplyPrice(detail.quantity, detail.price)
}))
}
/** 添加商品 */
const handleAddDetail = () => {
@ -354,9 +357,9 @@ const handleDetailTotalPriceChange = (detail: ReceiptOrderDetailVO) => {
detail.price = dividePrice(detail.totalPrice, detail.quantity)
}
/** 明细合计 */
const getDetailSummaries = ({ columns, data }: { columns: any[]; data: ReceiptOrderDetailVO[] }) =>
columns.map((column, index) => {
/** 计算表格的合计行数据 */
function getDetailSummaries({ columns, data }: { columns: any[]; data: ReceiptOrderDetailVO[] }) {
return columns.map((column, index) => {
if (index === 0) {
return '合计'
}
@ -371,6 +374,7 @@ const getDetailSummaries = ({ columns, data }: { columns: any[]; data: ReceiptOr
}
return ''
})
}
/** 校验明细 */
const validateDetails = (required: boolean) => {

View File

@ -450,35 +450,43 @@ const checkedTableColumns = ref<TableColumnKey[]>([
'operateInfo',
'remark'
])
const isTableColumnVisible = (column: TableColumnKey) => checkedTableColumns.value.includes(column)
const loading = ref(true) //
const list = ref<ReceiptOrderVO[]>([]) //
const total = ref(0) //
const getDefaultQueryParams = () => ({
pageNo: 1,
pageSize: 10,
no: undefined as string | undefined,
status: undefined as number | undefined,
warehouseId: undefined as number | undefined,
merchantId: undefined as number | undefined,
orderTime: undefined as string[] | undefined,
totalQuantityMin: undefined as number | undefined,
totalQuantityMax: undefined as number | undefined,
totalPriceMin: undefined as number | undefined,
totalPriceMax: undefined as number | undefined,
type: undefined as number | undefined,
bizOrderNo: undefined as string | undefined,
creator: undefined as number | undefined,
updater: undefined as number | undefined,
createTime: undefined as string[] | undefined,
updateTime: undefined as string[] | undefined
})
/** 获得默认的查询参数 */
function getDefaultQueryParams() {
return {
pageNo: 1,
pageSize: 10,
no: undefined as string | undefined,
status: undefined as number | undefined,
warehouseId: undefined as number | undefined,
merchantId: undefined as number | undefined,
orderTime: undefined as string[] | undefined,
totalQuantityMin: undefined as number | undefined,
totalQuantityMax: undefined as number | undefined,
totalPriceMin: undefined as number | undefined,
totalPriceMax: undefined as number | undefined,
type: undefined as number | undefined,
bizOrderNo: undefined as string | undefined,
creator: undefined as number | undefined,
updater: undefined as number | undefined,
createTime: undefined as string[] | undefined,
updateTime: undefined as string[] | undefined
}
}
const queryParams = reactive(getDefaultQueryParams())
const queryFormRef = ref() //
const exportLoading = ref(false) //
const detailMap = reactive<Record<number, ReceiptOrderDetailVO[]>>({}) //
/** 判断表格列是否可见 */
function isTableColumnVisible(column: TableColumnKey) {
return checkedTableColumns.value.includes(column)
}
/** 是否允许修改入库单 */
const canUpdateReceiptOrder = (status?: number) => {
return status !== undefined && OrderUpdateStatusList.includes(status)

View File

@ -127,8 +127,9 @@ const detailRows = computed<DetailRow[]>(() =>
}))
)
const getSummaries = ({ columns, data }: { columns: any[]; data: DetailRow[] }) =>
columns.map((column, index) => {
/** 计算表格的合计行数据 */
function getSummaries({ columns, data }: { columns: any[]; data: DetailRow[] }) {
return columns.map((column, index) => {
if (index === 0) {
return '合计'
}
@ -143,6 +144,7 @@ const getSummaries = ({ columns, data }: { columns: any[]; data: DetailRow[] })
}
return ''
})
}
/** 打开弹窗 */
const open = async (id: number) => {

View File

@ -293,28 +293,31 @@ const open = async (type: string, id?: number) => {
defineExpose({ open }) // open
/** 构建出库明细 */
const buildDetail = (inventory: InventorySelectRow): ShipmentOrderDetailVO => ({
id: undefined,
itemId: inventory.itemId,
itemCode: inventory.itemCode,
itemName: inventory.itemName,
unit: inventory.unit,
skuId: inventory.skuId,
skuCode: inventory.skuCode,
skuName: inventory.skuName,
warehouseId: inventory.warehouseId,
warehouseName: inventory.warehouseName,
quantity: undefined,
availableQuantity: inventory.availableQuantity,
price: undefined,
totalPrice: undefined
})
function buildDetail(inventory: InventorySelectRow): ShipmentOrderDetailVO {
return {
id: undefined,
itemId: inventory.itemId,
itemCode: inventory.itemCode,
itemName: inventory.itemName,
unit: inventory.unit,
skuId: inventory.skuId,
skuCode: inventory.skuCode,
skuName: inventory.skuName,
warehouseId: inventory.warehouseId,
warehouseName: inventory.warehouseName,
quantity: undefined,
availableQuantity: inventory.availableQuantity,
price: undefined,
totalPrice: undefined
}
}
const normalizeDetails = (details: ShipmentOrderDetailVO[]) =>
details.map((detail) => ({
function normalizeDetails(details: ShipmentOrderDetailVO[]) {
return details.map((detail) => ({
...detail,
totalPrice: detail.totalPrice ?? multiplyPrice(detail.quantity, detail.price)
}))
}
/** 添加商品 */
const handleAddDetail = () => {
@ -371,9 +374,9 @@ const handleDetailTotalPriceChange = (detail: ShipmentOrderDetailVO) => {
detail.price = dividePrice(detail.totalPrice, detail.quantity)
}
/** 明细合计 */
const getDetailSummaries = ({ columns, data }: { columns: any[]; data: ShipmentOrderDetailVO[] }) =>
columns.map((column, index) => {
/** 计算表格的合计行数据 */
function getDetailSummaries({ columns, data }: { columns: any[]; data: ShipmentOrderDetailVO[] }) {
return columns.map((column, index) => {
if (index === 0) {
return '合计'
}
@ -388,6 +391,7 @@ const getDetailSummaries = ({ columns, data }: { columns: any[]; data: ShipmentO
}
return ''
})
}
/** 校验明细 */
const validateDetails = (required: boolean) => {

View File

@ -450,35 +450,43 @@ const checkedTableColumns = ref<TableColumnKey[]>([
'operateInfo',
'remark'
])
const isTableColumnVisible = (column: TableColumnKey) => checkedTableColumns.value.includes(column)
const loading = ref(true) //
const list = ref<ShipmentOrderVO[]>([]) //
const total = ref(0) //
const getDefaultQueryParams = () => ({
pageNo: 1,
pageSize: 10,
no: undefined as string | undefined,
status: undefined as number | undefined,
warehouseId: undefined as number | undefined,
merchantId: undefined as number | undefined,
orderTime: undefined as string[] | undefined,
totalQuantityMin: undefined as number | undefined,
totalQuantityMax: undefined as number | undefined,
totalPriceMin: undefined as number | undefined,
totalPriceMax: undefined as number | undefined,
type: undefined as number | undefined,
bizOrderNo: undefined as string | undefined,
creator: undefined as number | undefined,
updater: undefined as number | undefined,
createTime: undefined as string[] | undefined,
updateTime: undefined as string[] | undefined
})
/** 获得默认的查询参数 */
function getDefaultQueryParams() {
return {
pageNo: 1,
pageSize: 10,
no: undefined as string | undefined,
status: undefined as number | undefined,
warehouseId: undefined as number | undefined,
merchantId: undefined as number | undefined,
orderTime: undefined as string[] | undefined,
totalQuantityMin: undefined as number | undefined,
totalQuantityMax: undefined as number | undefined,
totalPriceMin: undefined as number | undefined,
totalPriceMax: undefined as number | undefined,
type: undefined as number | undefined,
bizOrderNo: undefined as string | undefined,
creator: undefined as number | undefined,
updater: undefined as number | undefined,
createTime: undefined as string[] | undefined,
updateTime: undefined as string[] | undefined
}
}
const queryParams = reactive(getDefaultQueryParams())
const queryFormRef = ref() //
const exportLoading = ref(false) //
const detailMap = reactive<Record<number, ShipmentOrderDetailVO[]>>({}) //
/** 判断表格列是否可见 */
function isTableColumnVisible(column: TableColumnKey) {
return checkedTableColumns.value.includes(column)
}
/** 是否允许修改出库单 */
const canUpdateShipmentOrder = (status?: number) => {
return status !== undefined && OrderUpdateStatusList.includes(status)

View File

@ -43,7 +43,7 @@ export const CustomerMerchantTypeList = [
*
*
*/
export const generateWmsCode = (prefix: string = ''): string => {
export function generateWmsCode(prefix: string = ''): string {
let result = ''
for (let i = 0; i < 8; i++) {
result += Math.floor(Math.random() * 10).toString()

View File

@ -15,7 +15,7 @@ export const WEIGHT_PRECISION = 3
/** 长宽高小数位 */
export const DIMENSION_PRECISION = 1
const toFiniteDecimal = (value: DecimalValue) => {
function toFiniteDecimal(value: DecimalValue) {
if (isNullOrUnDef(value)) {
return undefined
}
@ -29,7 +29,7 @@ const toFiniteDecimal = (value: DecimalValue) => {
return decimalValue
}
const sumDecimal = <T>(list: T[], getter: (item: T) => DecimalValue) => {
function sumDecimal<T>(list: T[], getter: (item: T) => DecimalValue) {
return list.reduce((sum, item) => {
const decimalValue = toFiniteDecimal(getter(item))
return decimalValue === undefined ? sum : sum + decimalValue
@ -37,30 +37,30 @@ const sumDecimal = <T>(list: T[], getter: (item: T) => DecimalValue) => {
}
/** 格式化数量 */
export const formatQuantity = (value?: number | string | null) => {
export function formatQuantity(value?: number | string | null) {
const decimalValue = toFiniteDecimal(value)
return decimalValue === undefined ? '' : decimalValue.toFixed(QUANTITY_PRECISION)
}
/** 格式化金额 */
export const formatPrice = (value?: number | string | null) => {
export function formatPrice(value?: number | string | null) {
const decimalValue = toFiniteDecimal(value)
return decimalValue === undefined ? '' : decimalValue.toFixed(PRICE_PRECISION)
}
/** 金额四舍五入 */
export const roundPrice = (value: number) => {
export function roundPrice(value: number) {
return Number.isFinite(value) ? Number(value.toFixed(PRICE_PRECISION)) : undefined
}
/** 亏损数字样式 */
export const getLossClass = (value?: number | string | null) => {
export function getLossClass(value?: number | string | null) {
const decimalValue = toFiniteDecimal(value)
return decimalValue !== undefined && decimalValue < 0 ? 'text-red-500' : ''
}
/** 数量 * 单价,计算金额 */
export const multiplyPrice = (quantity?: number, price?: number) => {
export function multiplyPrice(quantity?: number, price?: number) {
if (quantity === undefined || quantity === null || price === undefined || price === null) {
return undefined
}
@ -68,7 +68,7 @@ export const multiplyPrice = (quantity?: number, price?: number) => {
}
/** 金额 / 数量,反算单价 */
export const dividePrice = (totalPrice?: number, quantity?: number) => {
export function dividePrice(totalPrice?: number, quantity?: number) {
if (totalPrice === undefined || totalPrice === null || !quantity) {
return undefined
}
@ -76,43 +76,43 @@ export const dividePrice = (totalPrice?: number, quantity?: number) => {
}
/** 汇总数量 */
export const sumQuantity = <T>(list: T[], getter: (item: T) => DecimalValue) => {
export function sumQuantity<T>(list: T[], getter: (item: T) => DecimalValue) {
return sumDecimal(list, getter)
}
/** 汇总金额 */
export const sumPrice = <T>(list: T[], getter: (item: T) => DecimalValue) => {
export function sumPrice<T>(list: T[], getter: (item: T) => DecimalValue) {
return sumDecimal(list, getter)
}
/** 格式化汇总数量 */
export const formatSumQuantity = <T>(list: T[], getter: (item: T) => DecimalValue) => {
export function formatSumQuantity<T>(list: T[], getter: (item: T) => DecimalValue) {
return formatQuantity(sumQuantity(list, getter))
}
/** 格式化汇总金额 */
export const formatSumPrice = <T>(list: T[], getter: (item: T) => DecimalValue) => {
export function formatSumPrice<T>(list: T[], getter: (item: T) => DecimalValue) {
return formatPrice(sumPrice(list, getter))
}
/** 格式化重量 */
export const formatWeight = (value?: number | string | null) => {
export function formatWeight(value?: number | string | null) {
const decimalValue = toFiniteDecimal(value)
return decimalValue === undefined ? '' : decimalValue.toFixed(WEIGHT_PRECISION)
}
/** 格式化长宽高 */
export const formatDimension = (value?: number | string | null) => {
export function formatDimension(value?: number | string | null) {
const decimalValue = toFiniteDecimal(value)
return decimalValue === undefined ? '' : decimalValue.toFixed(DIMENSION_PRECISION)
}
/** 格式化长宽高组合 */
export const formatDimensionText = (
export function formatDimensionText(
length?: number | string | null,
width?: number | string | null,
height?: number | string | null
) => {
) {
if (!isNullOrUnDef(length) && !isNullOrUnDef(width) && !isNullOrUnDef(height)) {
return [formatDimension(length), formatDimension(width), formatDimension(height)].join(' * ')
}

View File

@ -3,7 +3,7 @@
*/
/** 生成业务单号:前缀 + 月日 + 4 位随机数 */
export const generateOrderNo = (prefix: string) => {
export function generateOrderNo(prefix: string) {
const now = new Date()
const month = String(now.getMonth() + 1).padStart(2, '0')
const day = String(now.getDate()).padStart(2, '0')