feat(wms):优化整体代码结构
parent
24343f66fc
commit
f82ae7e0c8
|
|
@ -63,7 +63,9 @@ const goodsShareList = ref<ChartItem[]>([])
|
||||||
const inventoryDistributionList = 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 =
|
const chartFontFamily =
|
||||||
"Inter, 'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif"
|
"Inter, 'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif"
|
||||||
|
|
|
||||||
|
|
@ -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 })
|
defineExpose({ load })
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -148,14 +148,18 @@ const total = ref(0) // 列表的总条数
|
||||||
const selectedMap = ref<Map<string, InventorySelectRow>>(new Map()) // 跨页已选择库存
|
const selectedMap = ref<Map<string, InventorySelectRow>>(new Map()) // 跨页已选择库存
|
||||||
const tableRef = ref<InstanceType<typeof ElTable>>() // 表格 Ref
|
const tableRef = ref<InstanceType<typeof ElTable>>() // 表格 Ref
|
||||||
const queryFormRef = ref() // 搜索的表单
|
const queryFormRef = ref() // 搜索的表单
|
||||||
const getDefaultQueryParams = () => ({
|
|
||||||
|
/** 获得默认的查询参数 */
|
||||||
|
function getDefaultQueryParams() {
|
||||||
|
return {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
itemName: undefined as string | undefined,
|
itemName: undefined as string | undefined,
|
||||||
itemCode: undefined as string | undefined,
|
itemCode: undefined as string | undefined,
|
||||||
skuName: undefined as string | undefined,
|
skuName: undefined as string | undefined,
|
||||||
skuCode: undefined as string | undefined
|
skuCode: undefined as string | undefined
|
||||||
})
|
}
|
||||||
|
}
|
||||||
const queryParams = reactive(getDefaultQueryParams())
|
const queryParams = reactive(getDefaultQueryParams())
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
|
|
|
||||||
|
|
@ -236,7 +236,8 @@ const open = async (type: string, id?: number) => {
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
/** 构建空规格 */
|
/** 构建空规格 */
|
||||||
const buildEmptySku = (): ItemSkuVO => ({
|
function buildEmptySku(): ItemSkuVO {
|
||||||
|
return {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
barCode: undefined,
|
barCode: undefined,
|
||||||
|
|
@ -248,7 +249,8 @@ const buildEmptySku = (): ItemSkuVO => ({
|
||||||
netWeight: undefined,
|
netWeight: undefined,
|
||||||
costPrice: undefined,
|
costPrice: undefined,
|
||||||
sellingPrice: undefined
|
sellingPrice: undefined
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 添加规格 */
|
/** 添加规格 */
|
||||||
const handleAddSku = () => {
|
const handleAddSku = () => {
|
||||||
|
|
|
||||||
|
|
@ -122,9 +122,13 @@ const getTree = async () => {
|
||||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
// 校验表单
|
// 校验表单
|
||||||
if (!formRef) return
|
if (!formRef) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const valid = await formRef.value.validate()
|
const valid = await formRef.value.validate()
|
||||||
if (!valid) return
|
if (!valid) {
|
||||||
|
return
|
||||||
|
}
|
||||||
// 提交请求
|
// 提交请求
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -104,20 +104,20 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="金额(元)" min-width="140">
|
<el-table-column label="金额(元)" min-width="140">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div v-if="hasValue(scope.row.costPrice)">
|
<div v-if="!isNullOrUnDef(scope.row.costPrice)">
|
||||||
成本价:{{ formatPrice(scope.row.costPrice) }}
|
成本价:{{ formatPrice(scope.row.costPrice) }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="hasValue(scope.row.sellingPrice)">
|
<div v-if="!isNullOrUnDef(scope.row.sellingPrice)">
|
||||||
销售价:{{ formatPrice(scope.row.sellingPrice) }}
|
销售价:{{ formatPrice(scope.row.sellingPrice) }}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="重量(kg)" min-width="140">
|
<el-table-column label="重量(kg)" min-width="140">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div v-if="hasValue(scope.row.netWeight)">
|
<div v-if="!isNullOrUnDef(scope.row.netWeight)">
|
||||||
净重:{{ formatWeight(scope.row.netWeight) }}
|
净重:{{ formatWeight(scope.row.netWeight) }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="hasValue(scope.row.grossWeight)">
|
<div v-if="!isNullOrUnDef(scope.row.grossWeight)">
|
||||||
毛重:{{ formatWeight(scope.row.grossWeight) }}
|
毛重:{{ formatWeight(scope.row.grossWeight) }}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -200,7 +200,6 @@ const queryParams = reactive<{
|
||||||
const queryFormRef = ref() // 搜索的表单
|
const queryFormRef = ref() // 搜索的表单
|
||||||
const categoryTreeRef = ref() // 分类树
|
const categoryTreeRef = ref() // 分类树
|
||||||
const exportLoading = ref(false) // 导出的加载中
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
const hasValue = (value?: number | string | null) => !isNullOrUnDef(value)
|
|
||||||
|
|
||||||
/** 查询商品列表 */
|
/** 查询商品列表 */
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,10 @@ const preselectDisabled = ref(true) // 是否回显已禁用的 SKU
|
||||||
const syncingSingleSelection = ref(false) // 单选模式同步表格勾选状态中
|
const syncingSingleSelection = ref(false) // 单选模式同步表格勾选状态中
|
||||||
const tableRef = ref<InstanceType<typeof ElTable>>() // 表格 Ref
|
const tableRef = ref<InstanceType<typeof ElTable>>() // 表格 Ref
|
||||||
const queryFormRef = ref() // 搜索的表单
|
const queryFormRef = ref() // 搜索的表单
|
||||||
const getDefaultQueryParams = () => ({
|
|
||||||
|
/** 获得默认的查询参数 */
|
||||||
|
function getDefaultQueryParams() {
|
||||||
|
return {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
itemName: undefined as string | undefined,
|
itemName: undefined as string | undefined,
|
||||||
|
|
@ -181,7 +184,8 @@ const getDefaultQueryParams = () => ({
|
||||||
name: undefined as string | undefined,
|
name: undefined as string | undefined,
|
||||||
code: undefined as string | undefined,
|
code: undefined as string | undefined,
|
||||||
barCode: undefined as string | undefined
|
barCode: undefined as string | undefined
|
||||||
})
|
}
|
||||||
|
}
|
||||||
const queryParams = reactive(getDefaultQueryParams())
|
const queryParams = reactive(getDefaultQueryParams())
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
|
|
|
||||||
|
|
@ -124,11 +124,16 @@ defineOptions({ name: 'WmsCheckOrderDetail' })
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const detailData = ref<CheckOrderVO>({})
|
const detailData = ref<CheckOrderVO>({})
|
||||||
const getOrderDifferencePrice = (order: CheckOrderVO) =>
|
|
||||||
roundPrice(Number(order.actualPrice || 0) - Number(order.totalPrice || 0))
|
function getOrderDifferencePrice(order: CheckOrderVO) {
|
||||||
const getDifferenceQuantity = (detail: CheckOrderDetailVO) =>
|
return roundPrice(Number(order.actualPrice || 0) - Number(order.totalPrice || 0))
|
||||||
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 (
|
if (
|
||||||
detail.checkQuantity === undefined ||
|
detail.checkQuantity === undefined ||
|
||||||
detail.checkQuantity === null ||
|
detail.checkQuantity === null ||
|
||||||
|
|
@ -139,19 +144,22 @@ const getActualPrice = (detail: CheckOrderDetailVO) => {
|
||||||
}
|
}
|
||||||
return roundPrice(Number(detail.checkQuantity) * Number(detail.price))
|
return roundPrice(Number(detail.checkQuantity) * Number(detail.price))
|
||||||
}
|
}
|
||||||
const getDifferencePrice = (detail: CheckOrderDetailVO) => {
|
function getDifferencePrice(detail: CheckOrderDetailVO) {
|
||||||
if (detail.price === undefined || detail.price === null) {
|
if (detail.price === undefined || detail.price === null) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
return roundPrice(getDifferenceQuantity(detail) * Number(detail.price))
|
return roundPrice(getDifferenceQuantity(detail) * Number(detail.price))
|
||||||
}
|
}
|
||||||
const renderLossText = (
|
function renderLossText(
|
||||||
value: number | string | null | undefined,
|
value: number | string | null | undefined,
|
||||||
formatter: (value?: number | string | null) => string
|
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) {
|
if (index === 0) {
|
||||||
return '合计'
|
return '合计'
|
||||||
}
|
}
|
||||||
|
|
@ -178,6 +186,7 @@ const getSummaries = ({ columns, data }: { columns: any[]; data: CheckOrderDetai
|
||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async (id: number) => {
|
const open = async (id: number) => {
|
||||||
|
|
|
||||||
|
|
@ -284,21 +284,31 @@ const warehouseFormRules = reactive<FormRules>({
|
||||||
warehouseId: [{ required: true, message: '仓库不能为空', trigger: 'change' }]
|
warehouseId: [{ required: true, message: '仓库不能为空', trigger: 'change' }]
|
||||||
})
|
})
|
||||||
|
|
||||||
const getDifferenceQuantity = (detail: CheckOrderFormDetail) =>
|
function getDifferenceQuantity(detail: CheckOrderFormDetail) {
|
||||||
Number(detail.checkQuantity || 0) - Number(detail.quantity || 0)
|
return 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)
|
function getBookPrice(detail: CheckOrderFormDetail) {
|
||||||
const getDifferencePrice = (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) {
|
if (detail.price === undefined || detail.price === null) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
return roundPrice(getDifferenceQuantity(detail) * Number(detail.price))
|
return roundPrice(getDifferenceQuantity(detail) * Number(detail.price))
|
||||||
}
|
}
|
||||||
const renderLossText = (
|
|
||||||
|
function renderLossText(
|
||||||
value: number | string | null | undefined,
|
value: number | string | null | undefined,
|
||||||
formatter: (value?: number | string | null) => string
|
formatter: (value?: number | string | null) => string
|
||||||
) => h('span', { class: getLossClass(value) }, formatter(value))
|
) {
|
||||||
|
return h('span', { class: getLossClass(value) }, formatter(value))
|
||||||
|
}
|
||||||
const totalQuantity = computed(() =>
|
const totalQuantity = computed(() =>
|
||||||
sumQuantity(formData.value.details || [], (detail) => getDifferenceQuantity(detail))
|
sumQuantity(formData.value.details || [], (detail) => getDifferenceQuantity(detail))
|
||||||
)
|
)
|
||||||
|
|
@ -369,7 +379,8 @@ const handleWarehouseSelect = (warehouse: WarehouseVO | undefined) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 构建盘库明细 */
|
/** 构建盘库明细 */
|
||||||
const buildDetail = (inventory: CheckInventoryRow): CheckOrderFormDetail => ({
|
function buildDetail(inventory: CheckInventoryRow): CheckOrderFormDetail {
|
||||||
|
return {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
itemId: inventory.itemId,
|
itemId: inventory.itemId,
|
||||||
itemCode: inventory.itemCode,
|
itemCode: inventory.itemCode,
|
||||||
|
|
@ -386,13 +397,15 @@ const buildDetail = (inventory: CheckInventoryRow): CheckOrderFormDetail => ({
|
||||||
availableQuantity: inventory.availableQuantity,
|
availableQuantity: inventory.availableQuantity,
|
||||||
price: inventory.price,
|
price: inventory.price,
|
||||||
actualPrice: multiplyPrice(inventory.availableQuantity, inventory.price)
|
actualPrice: multiplyPrice(inventory.availableQuantity, inventory.price)
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const normalizeDetails = (details: CheckOrderDetailVO[]) =>
|
function normalizeDetails(details: CheckOrderDetailVO[]) {
|
||||||
details.map((detail) => ({
|
return details.map((detail) => ({
|
||||||
...detail,
|
...detail,
|
||||||
actualPrice: multiplyPrice(detail.checkQuantity, detail.price)
|
actualPrice: multiplyPrice(detail.checkQuantity, detail.price)
|
||||||
}))
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
/** 导入当前仓库的全部库存余额 */
|
/** 导入当前仓库的全部库存余额 */
|
||||||
const handleImportAllInventory = async () => {
|
const handleImportAllInventory = async () => {
|
||||||
|
|
@ -473,7 +486,8 @@ const getWarehouseInventoryMap = async (): Promise<Map<number, InventoryVO>> =>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 构建零库存盘库明细 */
|
/** 构建零库存盘库明细 */
|
||||||
const buildZeroInventoryDetail = (sku: ItemSkuVO): CheckOrderFormDetail => ({
|
function buildZeroInventoryDetail(sku: ItemSkuVO): CheckOrderFormDetail {
|
||||||
|
return {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
itemId: sku.itemId,
|
itemId: sku.itemId,
|
||||||
itemCode: sku.itemCode,
|
itemCode: sku.itemCode,
|
||||||
|
|
@ -490,7 +504,8 @@ const buildZeroInventoryDetail = (sku: ItemSkuVO): CheckOrderFormDetail => ({
|
||||||
availableQuantity: 0,
|
availableQuantity: 0,
|
||||||
price: sku.costPrice,
|
price: sku.costPrice,
|
||||||
actualPrice: 0
|
actualPrice: 0
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const handleDeleteDetail = (index: number) => {
|
const handleDeleteDetail = (index: number) => {
|
||||||
formData.value.details?.splice(index, 1)
|
formData.value.details?.splice(index, 1)
|
||||||
|
|
@ -512,20 +527,30 @@ const handleDetailActualPriceChange = (detail: CheckOrderFormDetail) => {
|
||||||
detail.price = dividePrice(detail.actualPrice, detail.checkQuantity)
|
detail.price = dividePrice(detail.actualPrice, detail.checkQuantity)
|
||||||
}
|
}
|
||||||
|
|
||||||
const getDetailSummaries = ({ columns, data }: { columns: any[]; data: CheckOrderFormDetail[] }) =>
|
/** 计算表格的合计行数据 */
|
||||||
columns.map((column, index) => {
|
function getDetailSummaries({ columns, data }: { columns: any[]; data: CheckOrderFormDetail[] }) {
|
||||||
if (index === 0) return '合计'
|
return columns.map((column, index) => {
|
||||||
if (column.property === 'quantity') return formatSumQuantity(data, (detail) => detail.quantity)
|
if (index === 0) {
|
||||||
if (column.property === 'checkQuantity')
|
return '合计'
|
||||||
|
}
|
||||||
|
if (column.property === 'quantity') {
|
||||||
|
return formatSumQuantity(data, (detail) => detail.quantity)
|
||||||
|
}
|
||||||
|
if (column.property === 'checkQuantity') {
|
||||||
return formatSumQuantity(data, (detail) => detail.checkQuantity)
|
return formatSumQuantity(data, (detail) => detail.checkQuantity)
|
||||||
if (column.property === 'actualPrice')
|
}
|
||||||
|
if (column.property === 'actualPrice') {
|
||||||
return formatSumPrice(data, (detail) => getActualPrice(detail))
|
return formatSumPrice(data, (detail) => getActualPrice(detail))
|
||||||
if (column.property === 'differenceQuantity')
|
}
|
||||||
|
if (column.property === 'differenceQuantity') {
|
||||||
return renderLossText(totalQuantity.value, formatQuantity)
|
return renderLossText(totalQuantity.value, formatQuantity)
|
||||||
if (column.property === 'differencePrice')
|
}
|
||||||
|
if (column.property === 'differencePrice') {
|
||||||
return renderLossText(differencePrice.value, formatPrice)
|
return renderLossText(differencePrice.value, formatPrice)
|
||||||
|
}
|
||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** 校验明细 */
|
/** 校验明细 */
|
||||||
const validateDetails = (required: boolean) => {
|
const validateDetails = (required: boolean) => {
|
||||||
|
|
@ -566,7 +591,9 @@ const buildSubmitData = () => {
|
||||||
const emit = defineEmits(['success'])
|
const emit = defineEmits(['success'])
|
||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
await formRef.value.validate()
|
await formRef.value.validate()
|
||||||
if (!validateDetails(false)) return
|
if (!validateDetails(false)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
const data = buildSubmitData()
|
const data = buildSubmitData()
|
||||||
|
|
@ -587,7 +614,9 @@ const submitForm = async () => {
|
||||||
/** 完成盘库:表单修改过则先保存,再完成 */
|
/** 完成盘库:表单修改过则先保存,再完成 */
|
||||||
const handleComplete = async () => {
|
const handleComplete = async () => {
|
||||||
await formRef.value.validate()
|
await formRef.value.validate()
|
||||||
if (!validateDetails(true)) return
|
if (!validateDetails(true)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await message.confirm('确认完成盘库?完成后将更新库存。')
|
await message.confirm('确认完成盘库?完成后将更新库存。')
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
|
|
|
||||||
|
|
@ -149,9 +149,11 @@ interface PrintRow extends CheckOrderDetailVO {
|
||||||
differencePrice?: number
|
differencePrice?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
const getDifferenceQuantity = (detail: CheckOrderDetailVO) =>
|
function getDifferenceQuantity(detail: CheckOrderDetailVO) {
|
||||||
Number(detail.checkQuantity || 0) - Number(detail.quantity || 0)
|
return Number(detail.checkQuantity || 0) - Number(detail.quantity || 0)
|
||||||
const getActualPrice = (detail: CheckOrderDetailVO) => {
|
}
|
||||||
|
|
||||||
|
function getActualPrice(detail: CheckOrderDetailVO) {
|
||||||
if (
|
if (
|
||||||
detail.checkQuantity === undefined ||
|
detail.checkQuantity === undefined ||
|
||||||
detail.checkQuantity === null ||
|
detail.checkQuantity === null ||
|
||||||
|
|
@ -162,14 +164,15 @@ const getActualPrice = (detail: CheckOrderDetailVO) => {
|
||||||
}
|
}
|
||||||
return roundPrice(Number(detail.checkQuantity) * Number(detail.price))
|
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) {
|
if (detail.price === undefined || detail.price === null) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
return roundPrice(differenceQuantity * Number(detail.price))
|
return roundPrice(differenceQuantity * Number(detail.price))
|
||||||
}
|
}
|
||||||
const getOrderDifferencePrice = (order: CheckOrderVO) =>
|
function getOrderDifferencePrice(order: CheckOrderVO) {
|
||||||
roundPrice(Number(order.actualPrice || 0) - Number(order.totalPrice || 0))
|
return roundPrice(Number(order.actualPrice || 0) - Number(order.totalPrice || 0))
|
||||||
|
}
|
||||||
const printRows = computed<PrintRow[]>(() =>
|
const printRows = computed<PrintRow[]>(() =>
|
||||||
(printData.value.details || []).map((detail) => {
|
(printData.value.details || []).map((detail) => {
|
||||||
const differenceQuantity = getDifferenceQuantity(detail)
|
const differenceQuantity = getDifferenceQuantity(detail)
|
||||||
|
|
|
||||||
|
|
@ -436,12 +436,14 @@ const checkedTableColumns = ref<TableColumnKey[]>([
|
||||||
'operateInfo',
|
'operateInfo',
|
||||||
'remark'
|
'remark'
|
||||||
])
|
])
|
||||||
const isTableColumnVisible = (column: TableColumnKey) => checkedTableColumns.value.includes(column)
|
|
||||||
|
|
||||||
const loading = ref(true) // 列表的加载中
|
const loading = ref(true) // 列表的加载中
|
||||||
const list = ref<CheckOrderVO[]>([]) // 列表的数据
|
const list = ref<CheckOrderVO[]>([]) // 列表的数据
|
||||||
const total = ref(0) // 列表的总页数
|
const total = ref(0) // 列表的总页数
|
||||||
const getDefaultQueryParams = () => ({
|
|
||||||
|
/** 获得默认的查询参数 */
|
||||||
|
function getDefaultQueryParams() {
|
||||||
|
return {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
no: undefined as string | undefined,
|
no: undefined as string | undefined,
|
||||||
|
|
@ -458,12 +460,18 @@ const getDefaultQueryParams = () => ({
|
||||||
updater: undefined as number | undefined,
|
updater: undefined as number | undefined,
|
||||||
createTime: undefined as string[] | undefined,
|
createTime: undefined as string[] | undefined,
|
||||||
updateTime: undefined as string[] | undefined
|
updateTime: undefined as string[] | undefined
|
||||||
})
|
}
|
||||||
|
}
|
||||||
const queryParams = reactive(getDefaultQueryParams())
|
const queryParams = reactive(getDefaultQueryParams())
|
||||||
const queryFormRef = ref() // 搜索的表单
|
const queryFormRef = ref() // 搜索的表单
|
||||||
const exportLoading = ref(false) // 导出的加载中
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
const detailMap = reactive<Record<number, CheckOrderDetailVO[]>>({}) // 盘库单明细数据
|
const detailMap = reactive<Record<number, CheckOrderDetailVO[]>>({}) // 盘库单明细数据
|
||||||
|
|
||||||
|
/** 判断表格列是否可见 */
|
||||||
|
function isTableColumnVisible(column: TableColumnKey) {
|
||||||
|
return checkedTableColumns.value.includes(column)
|
||||||
|
}
|
||||||
|
|
||||||
/** 是否允许修改盘库单 */
|
/** 是否允许修改盘库单 */
|
||||||
const canUpdateCheckOrder = (status?: number) => {
|
const canUpdateCheckOrder = (status?: number) => {
|
||||||
return status !== undefined && OrderUpdateStatusList.includes(status)
|
return status !== undefined && OrderUpdateStatusList.includes(status)
|
||||||
|
|
|
||||||
|
|
@ -110,14 +110,24 @@ const detailRows = computed<DetailRow[]>(() =>
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
|
|
||||||
const getSummaries = ({ columns, data }: { columns: any[]; data: DetailRow[] }) =>
|
/** 计算表格的合计行数据 */
|
||||||
columns.map((column, index) => {
|
function getSummaries({ columns, data }: { columns: any[]; data: DetailRow[] }) {
|
||||||
if (index === 0) return '合计'
|
return columns.map((column, index) => {
|
||||||
if (column.property === 'quantity') return formatSumQuantity(data, (detail) => detail.quantity)
|
if (index === 0) {
|
||||||
if (column.property === 'price') return formatSumPrice(data, (detail) => detail.price)
|
return '合计'
|
||||||
if (column.property === 'totalPrice') return formatSumPrice(data, (detail) => detail.totalPrice)
|
}
|
||||||
|
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 ''
|
return ''
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async (id: number) => {
|
const open = async (id: number) => {
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,8 @@ const open = async (type: string, id?: number) => {
|
||||||
defineExpose({ open })
|
defineExpose({ open })
|
||||||
|
|
||||||
/** 构建移库明细 */
|
/** 构建移库明细 */
|
||||||
const buildDetail = (inventory: InventorySelectRow): MovementOrderDetailVO => ({
|
function buildDetail(inventory: InventorySelectRow): MovementOrderDetailVO {
|
||||||
|
return {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
itemId: inventory.itemId,
|
itemId: inventory.itemId,
|
||||||
itemCode: inventory.itemCode,
|
itemCode: inventory.itemCode,
|
||||||
|
|
@ -295,13 +296,15 @@ const buildDetail = (inventory: InventorySelectRow): MovementOrderDetailVO => ({
|
||||||
availableQuantity: inventory.availableQuantity,
|
availableQuantity: inventory.availableQuantity,
|
||||||
price: undefined,
|
price: undefined,
|
||||||
totalPrice: undefined
|
totalPrice: undefined
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const normalizeDetails = (details: MovementOrderDetailVO[]) =>
|
function normalizeDetails(details: MovementOrderDetailVO[]) {
|
||||||
details.map((detail) => ({
|
return details.map((detail) => ({
|
||||||
...detail,
|
...detail,
|
||||||
totalPrice: detail.totalPrice ?? multiplyPrice(detail.quantity, detail.price)
|
totalPrice: detail.totalPrice ?? multiplyPrice(detail.quantity, detail.price)
|
||||||
}))
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
/** 打开库存选择弹窗 */
|
/** 打开库存选择弹窗 */
|
||||||
const handleAddDetail = () => {
|
const handleAddDetail = () => {
|
||||||
|
|
@ -313,19 +316,24 @@ const handleAddDetail = () => {
|
||||||
|
|
||||||
/** 选择库存 */
|
/** 选择库存 */
|
||||||
const handleSelectInventory = (inventories: InventorySelectRow[]) => {
|
const handleSelectInventory = (inventories: InventorySelectRow[]) => {
|
||||||
if (!inventories.length) return
|
if (!inventories.length) {
|
||||||
|
return
|
||||||
|
}
|
||||||
formData.value.details = formData.value.details || []
|
formData.value.details = formData.value.details || []
|
||||||
inventories.forEach((inventory) => {
|
inventories.forEach((inventory) => {
|
||||||
if (isInventorySelected(inventory)) return
|
if (isInventorySelected(inventory)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
formData.value.details!.push(buildDetail(inventory))
|
formData.value.details!.push(buildDetail(inventory))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 判断库存是否已选择 */
|
/** 判断库存是否已选择 */
|
||||||
const isInventorySelected = (inventory: InventorySelectRow) =>
|
function isInventorySelected(inventory: InventorySelectRow) {
|
||||||
(formData.value.details || []).some((detail) => {
|
return (formData.value.details || []).some((detail) => {
|
||||||
return detail.skuId === inventory.skuId && detail.sourceWarehouseId === inventory.warehouseId
|
return detail.skuId === inventory.skuId && detail.sourceWarehouseId === inventory.warehouseId
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const handleDeleteDetail = (index: number) => {
|
const handleDeleteDetail = (index: number) => {
|
||||||
formData.value.details?.splice(index, 1)
|
formData.value.details?.splice(index, 1)
|
||||||
|
|
@ -360,8 +368,15 @@ const handleDetailTotalPriceChange = (detail: MovementOrderDetailVO) => {
|
||||||
detail.price = dividePrice(detail.totalPrice, detail.quantity)
|
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) {
|
if (index === 0) {
|
||||||
return '合计'
|
return '合计'
|
||||||
}
|
}
|
||||||
|
|
@ -376,6 +391,7 @@ const getDetailSummaries = ({ columns, data }: { columns: any[]; data: MovementO
|
||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** 校验明细 */
|
/** 校验明细 */
|
||||||
const validateDetails = (required: boolean) => {
|
const validateDetails = (required: boolean) => {
|
||||||
|
|
@ -421,7 +437,9 @@ const buildSubmitData = () => {
|
||||||
const emit = defineEmits(['success'])
|
const emit = defineEmits(['success'])
|
||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
await formRef.value.validate()
|
await formRef.value.validate()
|
||||||
if (!validateDetails(false)) return
|
if (!validateDetails(false)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
const data = buildSubmitData()
|
const data = buildSubmitData()
|
||||||
|
|
@ -442,7 +460,9 @@ const submitForm = async () => {
|
||||||
/** 完成移库:表单修改过则先保存,再完成 */
|
/** 完成移库:表单修改过则先保存,再完成 */
|
||||||
const handleComplete = async () => {
|
const handleComplete = async () => {
|
||||||
await formRef.value.validate()
|
await formRef.value.validate()
|
||||||
if (!validateDetails(true)) return
|
if (!validateDetails(true)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await message.confirm('确认完成移库?完成后将更新库存。')
|
await message.confirm('确认完成移库?完成后将更新库存。')
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
|
|
|
||||||
|
|
@ -399,12 +399,14 @@ const checkedTableColumns = ref<TableColumnKey[]>([
|
||||||
'operateInfo',
|
'operateInfo',
|
||||||
'remark'
|
'remark'
|
||||||
])
|
])
|
||||||
const isTableColumnVisible = (column: TableColumnKey) => checkedTableColumns.value.includes(column)
|
|
||||||
|
|
||||||
const loading = ref(true) // 列表的加载中
|
const loading = ref(true) // 列表的加载中
|
||||||
const list = ref<MovementOrderVO[]>([]) // 列表的数据
|
const list = ref<MovementOrderVO[]>([]) // 列表的数据
|
||||||
const total = ref(0) // 列表的总页数
|
const total = ref(0) // 列表的总页数
|
||||||
const getDefaultQueryParams = () => ({
|
|
||||||
|
/** 获得默认的查询参数 */
|
||||||
|
function getDefaultQueryParams() {
|
||||||
|
return {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
no: undefined as string | undefined,
|
no: undefined as string | undefined,
|
||||||
|
|
@ -420,12 +422,18 @@ const getDefaultQueryParams = () => ({
|
||||||
updater: undefined as number | undefined,
|
updater: undefined as number | undefined,
|
||||||
createTime: undefined as string[] | undefined,
|
createTime: undefined as string[] | undefined,
|
||||||
updateTime: undefined as string[] | undefined
|
updateTime: undefined as string[] | undefined
|
||||||
})
|
}
|
||||||
|
}
|
||||||
const queryParams = reactive(getDefaultQueryParams())
|
const queryParams = reactive(getDefaultQueryParams())
|
||||||
const queryFormRef = ref() // 搜索的表单
|
const queryFormRef = ref() // 搜索的表单
|
||||||
const exportLoading = ref(false) // 导出的加载中
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
const detailMap = reactive<Record<number, MovementOrderDetailVO[]>>({}) // 移库单明细数据
|
const detailMap = reactive<Record<number, MovementOrderDetailVO[]>>({}) // 移库单明细数据
|
||||||
|
|
||||||
|
/** 判断表格列是否可见 */
|
||||||
|
function isTableColumnVisible(column: TableColumnKey) {
|
||||||
|
return checkedTableColumns.value.includes(column)
|
||||||
|
}
|
||||||
|
|
||||||
/** 是否允许修改移库单 */
|
/** 是否允许修改移库单 */
|
||||||
const canUpdateMovementOrder = (status?: number) => {
|
const canUpdateMovementOrder = (status?: number) => {
|
||||||
return status !== undefined && OrderUpdateStatusList.includes(status)
|
return status !== undefined && OrderUpdateStatusList.includes(status)
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
if (index === 0) {
|
||||||
return '合计'
|
return '合计'
|
||||||
}
|
}
|
||||||
|
|
@ -143,6 +144,7 @@ const getSummaries = ({ columns, data }: { columns: any[]; data: DetailRow[] })
|
||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async (id: number) => {
|
const open = async (id: number) => {
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,8 @@ const open = async (type: string, id?: number) => {
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
/** 构建入库明细 */
|
/** 构建入库明细 */
|
||||||
const buildDetail = (sku: ItemSkuVO): ReceiptOrderDetailVO => ({
|
function buildDetail(sku: ItemSkuVO): ReceiptOrderDetailVO {
|
||||||
|
return {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
itemId: sku.itemId,
|
itemId: sku.itemId,
|
||||||
itemCode: sku.itemCode,
|
itemCode: sku.itemCode,
|
||||||
|
|
@ -294,13 +295,15 @@ const buildDetail = (sku: ItemSkuVO): ReceiptOrderDetailVO => ({
|
||||||
quantity: undefined,
|
quantity: undefined,
|
||||||
price: undefined,
|
price: undefined,
|
||||||
totalPrice: undefined
|
totalPrice: undefined
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const normalizeDetails = (details: ReceiptOrderDetailVO[]) =>
|
function normalizeDetails(details: ReceiptOrderDetailVO[]) {
|
||||||
details.map((detail) => ({
|
return details.map((detail) => ({
|
||||||
...detail,
|
...detail,
|
||||||
totalPrice: detail.totalPrice ?? multiplyPrice(detail.quantity, detail.price)
|
totalPrice: detail.totalPrice ?? multiplyPrice(detail.quantity, detail.price)
|
||||||
}))
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
/** 添加商品 */
|
/** 添加商品 */
|
||||||
const handleAddDetail = () => {
|
const handleAddDetail = () => {
|
||||||
|
|
@ -354,9 +357,9 @@ const handleDetailTotalPriceChange = (detail: ReceiptOrderDetailVO) => {
|
||||||
detail.price = dividePrice(detail.totalPrice, detail.quantity)
|
detail.price = dividePrice(detail.totalPrice, detail.quantity)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 明细合计 */
|
/** 计算表格的合计行数据 */
|
||||||
const getDetailSummaries = ({ columns, data }: { columns: any[]; data: ReceiptOrderDetailVO[] }) =>
|
function getDetailSummaries({ columns, data }: { columns: any[]; data: ReceiptOrderDetailVO[] }) {
|
||||||
columns.map((column, index) => {
|
return columns.map((column, index) => {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
return '合计'
|
return '合计'
|
||||||
}
|
}
|
||||||
|
|
@ -371,6 +374,7 @@ const getDetailSummaries = ({ columns, data }: { columns: any[]; data: ReceiptOr
|
||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** 校验明细 */
|
/** 校验明细 */
|
||||||
const validateDetails = (required: boolean) => {
|
const validateDetails = (required: boolean) => {
|
||||||
|
|
|
||||||
|
|
@ -450,12 +450,14 @@ const checkedTableColumns = ref<TableColumnKey[]>([
|
||||||
'operateInfo',
|
'operateInfo',
|
||||||
'remark'
|
'remark'
|
||||||
])
|
])
|
||||||
const isTableColumnVisible = (column: TableColumnKey) => checkedTableColumns.value.includes(column)
|
|
||||||
|
|
||||||
const loading = ref(true) // 列表的加载中
|
const loading = ref(true) // 列表的加载中
|
||||||
const list = ref<ReceiptOrderVO[]>([]) // 列表的数据
|
const list = ref<ReceiptOrderVO[]>([]) // 列表的数据
|
||||||
const total = ref(0) // 列表的总页数
|
const total = ref(0) // 列表的总页数
|
||||||
const getDefaultQueryParams = () => ({
|
|
||||||
|
/** 获得默认的查询参数 */
|
||||||
|
function getDefaultQueryParams() {
|
||||||
|
return {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
no: undefined as string | undefined,
|
no: undefined as string | undefined,
|
||||||
|
|
@ -473,12 +475,18 @@ const getDefaultQueryParams = () => ({
|
||||||
updater: undefined as number | undefined,
|
updater: undefined as number | undefined,
|
||||||
createTime: undefined as string[] | undefined,
|
createTime: undefined as string[] | undefined,
|
||||||
updateTime: undefined as string[] | undefined
|
updateTime: undefined as string[] | undefined
|
||||||
})
|
}
|
||||||
|
}
|
||||||
const queryParams = reactive(getDefaultQueryParams())
|
const queryParams = reactive(getDefaultQueryParams())
|
||||||
const queryFormRef = ref() // 搜索的表单
|
const queryFormRef = ref() // 搜索的表单
|
||||||
const exportLoading = ref(false) // 导出的加载中
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
const detailMap = reactive<Record<number, ReceiptOrderDetailVO[]>>({}) // 入库单明细数据
|
const detailMap = reactive<Record<number, ReceiptOrderDetailVO[]>>({}) // 入库单明细数据
|
||||||
|
|
||||||
|
/** 判断表格列是否可见 */
|
||||||
|
function isTableColumnVisible(column: TableColumnKey) {
|
||||||
|
return checkedTableColumns.value.includes(column)
|
||||||
|
}
|
||||||
|
|
||||||
/** 是否允许修改入库单 */
|
/** 是否允许修改入库单 */
|
||||||
const canUpdateReceiptOrder = (status?: number) => {
|
const canUpdateReceiptOrder = (status?: number) => {
|
||||||
return status !== undefined && OrderUpdateStatusList.includes(status)
|
return status !== undefined && OrderUpdateStatusList.includes(status)
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
if (index === 0) {
|
||||||
return '合计'
|
return '合计'
|
||||||
}
|
}
|
||||||
|
|
@ -143,6 +144,7 @@ const getSummaries = ({ columns, data }: { columns: any[]; data: DetailRow[] })
|
||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async (id: number) => {
|
const open = async (id: number) => {
|
||||||
|
|
|
||||||
|
|
@ -293,7 +293,8 @@ const open = async (type: string, id?: number) => {
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
/** 构建出库明细 */
|
/** 构建出库明细 */
|
||||||
const buildDetail = (inventory: InventorySelectRow): ShipmentOrderDetailVO => ({
|
function buildDetail(inventory: InventorySelectRow): ShipmentOrderDetailVO {
|
||||||
|
return {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
itemId: inventory.itemId,
|
itemId: inventory.itemId,
|
||||||
itemCode: inventory.itemCode,
|
itemCode: inventory.itemCode,
|
||||||
|
|
@ -308,13 +309,15 @@ const buildDetail = (inventory: InventorySelectRow): ShipmentOrderDetailVO => ({
|
||||||
availableQuantity: inventory.availableQuantity,
|
availableQuantity: inventory.availableQuantity,
|
||||||
price: undefined,
|
price: undefined,
|
||||||
totalPrice: undefined
|
totalPrice: undefined
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const normalizeDetails = (details: ShipmentOrderDetailVO[]) =>
|
function normalizeDetails(details: ShipmentOrderDetailVO[]) {
|
||||||
details.map((detail) => ({
|
return details.map((detail) => ({
|
||||||
...detail,
|
...detail,
|
||||||
totalPrice: detail.totalPrice ?? multiplyPrice(detail.quantity, detail.price)
|
totalPrice: detail.totalPrice ?? multiplyPrice(detail.quantity, detail.price)
|
||||||
}))
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
/** 添加商品 */
|
/** 添加商品 */
|
||||||
const handleAddDetail = () => {
|
const handleAddDetail = () => {
|
||||||
|
|
@ -371,9 +374,9 @@ const handleDetailTotalPriceChange = (detail: ShipmentOrderDetailVO) => {
|
||||||
detail.price = dividePrice(detail.totalPrice, detail.quantity)
|
detail.price = dividePrice(detail.totalPrice, detail.quantity)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 明细合计 */
|
/** 计算表格的合计行数据 */
|
||||||
const getDetailSummaries = ({ columns, data }: { columns: any[]; data: ShipmentOrderDetailVO[] }) =>
|
function getDetailSummaries({ columns, data }: { columns: any[]; data: ShipmentOrderDetailVO[] }) {
|
||||||
columns.map((column, index) => {
|
return columns.map((column, index) => {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
return '合计'
|
return '合计'
|
||||||
}
|
}
|
||||||
|
|
@ -388,6 +391,7 @@ const getDetailSummaries = ({ columns, data }: { columns: any[]; data: ShipmentO
|
||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** 校验明细 */
|
/** 校验明细 */
|
||||||
const validateDetails = (required: boolean) => {
|
const validateDetails = (required: boolean) => {
|
||||||
|
|
|
||||||
|
|
@ -450,12 +450,14 @@ const checkedTableColumns = ref<TableColumnKey[]>([
|
||||||
'operateInfo',
|
'operateInfo',
|
||||||
'remark'
|
'remark'
|
||||||
])
|
])
|
||||||
const isTableColumnVisible = (column: TableColumnKey) => checkedTableColumns.value.includes(column)
|
|
||||||
|
|
||||||
const loading = ref(true) // 列表的加载中
|
const loading = ref(true) // 列表的加载中
|
||||||
const list = ref<ShipmentOrderVO[]>([]) // 列表的数据
|
const list = ref<ShipmentOrderVO[]>([]) // 列表的数据
|
||||||
const total = ref(0) // 列表的总页数
|
const total = ref(0) // 列表的总页数
|
||||||
const getDefaultQueryParams = () => ({
|
|
||||||
|
/** 获得默认的查询参数 */
|
||||||
|
function getDefaultQueryParams() {
|
||||||
|
return {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
no: undefined as string | undefined,
|
no: undefined as string | undefined,
|
||||||
|
|
@ -473,12 +475,18 @@ const getDefaultQueryParams = () => ({
|
||||||
updater: undefined as number | undefined,
|
updater: undefined as number | undefined,
|
||||||
createTime: undefined as string[] | undefined,
|
createTime: undefined as string[] | undefined,
|
||||||
updateTime: undefined as string[] | undefined
|
updateTime: undefined as string[] | undefined
|
||||||
})
|
}
|
||||||
|
}
|
||||||
const queryParams = reactive(getDefaultQueryParams())
|
const queryParams = reactive(getDefaultQueryParams())
|
||||||
const queryFormRef = ref() // 搜索的表单
|
const queryFormRef = ref() // 搜索的表单
|
||||||
const exportLoading = ref(false) // 导出的加载中
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
const detailMap = reactive<Record<number, ShipmentOrderDetailVO[]>>({}) // 出库单明细数据
|
const detailMap = reactive<Record<number, ShipmentOrderDetailVO[]>>({}) // 出库单明细数据
|
||||||
|
|
||||||
|
/** 判断表格列是否可见 */
|
||||||
|
function isTableColumnVisible(column: TableColumnKey) {
|
||||||
|
return checkedTableColumns.value.includes(column)
|
||||||
|
}
|
||||||
|
|
||||||
/** 是否允许修改出库单 */
|
/** 是否允许修改出库单 */
|
||||||
const canUpdateShipmentOrder = (status?: number) => {
|
const canUpdateShipmentOrder = (status?: number) => {
|
||||||
return status !== undefined && OrderUpdateStatusList.includes(status)
|
return status !== undefined && OrderUpdateStatusList.includes(status)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ export const CustomerMerchantTypeList = [
|
||||||
*
|
*
|
||||||
* 由前端在表单【生成】按钮上调用,避免后端兜底生成造成编号不可控。
|
* 由前端在表单【生成】按钮上调用,避免后端兜底生成造成编号不可控。
|
||||||
*/
|
*/
|
||||||
export const generateWmsCode = (prefix: string = ''): string => {
|
export function generateWmsCode(prefix: string = ''): string {
|
||||||
let result = ''
|
let result = ''
|
||||||
for (let i = 0; i < 8; i++) {
|
for (let i = 0; i < 8; i++) {
|
||||||
result += Math.floor(Math.random() * 10).toString()
|
result += Math.floor(Math.random() * 10).toString()
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ export const WEIGHT_PRECISION = 3
|
||||||
/** 长宽高小数位 */
|
/** 长宽高小数位 */
|
||||||
export const DIMENSION_PRECISION = 1
|
export const DIMENSION_PRECISION = 1
|
||||||
|
|
||||||
const toFiniteDecimal = (value: DecimalValue) => {
|
function toFiniteDecimal(value: DecimalValue) {
|
||||||
if (isNullOrUnDef(value)) {
|
if (isNullOrUnDef(value)) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ const toFiniteDecimal = (value: DecimalValue) => {
|
||||||
return 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) => {
|
return list.reduce((sum, item) => {
|
||||||
const decimalValue = toFiniteDecimal(getter(item))
|
const decimalValue = toFiniteDecimal(getter(item))
|
||||||
return decimalValue === undefined ? sum : sum + decimalValue
|
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)
|
const decimalValue = toFiniteDecimal(value)
|
||||||
return decimalValue === undefined ? '' : decimalValue.toFixed(QUANTITY_PRECISION)
|
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)
|
const decimalValue = toFiniteDecimal(value)
|
||||||
return decimalValue === undefined ? '' : decimalValue.toFixed(PRICE_PRECISION)
|
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
|
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)
|
const decimalValue = toFiniteDecimal(value)
|
||||||
return decimalValue !== undefined && decimalValue < 0 ? 'text-red-500' : ''
|
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) {
|
if (quantity === undefined || quantity === null || price === undefined || price === null) {
|
||||||
return undefined
|
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) {
|
if (totalPrice === undefined || totalPrice === null || !quantity) {
|
||||||
return undefined
|
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)
|
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)
|
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))
|
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))
|
return formatPrice(sumPrice(list, getter))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 格式化重量 */
|
/** 格式化重量 */
|
||||||
export const formatWeight = (value?: number | string | null) => {
|
export function formatWeight(value?: number | string | null) {
|
||||||
const decimalValue = toFiniteDecimal(value)
|
const decimalValue = toFiniteDecimal(value)
|
||||||
return decimalValue === undefined ? '' : decimalValue.toFixed(WEIGHT_PRECISION)
|
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)
|
const decimalValue = toFiniteDecimal(value)
|
||||||
return decimalValue === undefined ? '' : decimalValue.toFixed(DIMENSION_PRECISION)
|
return decimalValue === undefined ? '' : decimalValue.toFixed(DIMENSION_PRECISION)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 格式化长宽高组合 */
|
/** 格式化长宽高组合 */
|
||||||
export const formatDimensionText = (
|
export function formatDimensionText(
|
||||||
length?: number | string | null,
|
length?: number | string | null,
|
||||||
width?: number | string | null,
|
width?: number | string | null,
|
||||||
height?: number | string | null
|
height?: number | string | null
|
||||||
) => {
|
) {
|
||||||
if (!isNullOrUnDef(length) && !isNullOrUnDef(width) && !isNullOrUnDef(height)) {
|
if (!isNullOrUnDef(length) && !isNullOrUnDef(width) && !isNullOrUnDef(height)) {
|
||||||
return [formatDimension(length), formatDimension(width), formatDimension(height)].join(' * ')
|
return [formatDimension(length), formatDimension(width), formatDimension(height)].join(' * ')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** 生成业务单号:前缀 + 月日 + 4 位随机数 */
|
/** 生成业务单号:前缀 + 月日 + 4 位随机数 */
|
||||||
export const generateOrderNo = (prefix: string) => {
|
export function generateOrderNo(prefix: string) {
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const month = String(now.getMonth() + 1).padStart(2, '0')
|
const month = String(now.getMonth() + 1).padStart(2, '0')
|
||||||
const day = String(now.getDate()).padStart(2, '0')
|
const day = String(now.getDate()).padStart(2, '0')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue