Commit e0a84a01 by wuqian

入库单第一版

parent d0b4ff7e
......@@ -14,15 +14,15 @@ export interface LogListData {
description: string
createdTime?: string | null
}
export interface PrintData{
code:string
list:{
locationName:string;
pickingLocation?:string
skuName?:string
warehouseSku?:string
supplierItemNo?:string
number?:string
export interface PrintData {
code: string
list: {
locationName: string
pickingLocation?: string
skuName?: string
warehouseSku?: string
supplierItemNo?: string
number?: string
}[]
}
export interface factoryWarehouseInfo {
......@@ -35,23 +35,22 @@ export interface factoryWarehouseInfo {
}
export interface WarehouseInventory {
pageSize: number;
currentPage: number;
total?: number;
warehouseId: string;
skuName: string;
warehouseSku: string;
occupyInventory: string;
inventoryStart: string;
inventoryEnd: string;
productNumber: string;
freezeInventory: string;
inventory: string;
usableInventoryStart: string;
usableInventoryEnd: string;
occupyInventoryEnd: string;
occupyInventoryStart: string;
pageSize: number
currentPage: number
total?: number
warehouseId: string
skuName: string
warehouseSku: string
occupyInventory: string
inventoryStart: string
inventoryEnd: string
productNumber: string
freezeInventory: string
inventory: string
usableInventoryStart: string
usableInventoryEnd: string
occupyInventoryEnd: string
occupyInventoryStart: string
}
export interface UpdateDefaulted {
......@@ -78,10 +77,10 @@ export interface warehouseInfo {
export interface WarehouseWarning {
id: number | string
locationCode: string
skuName: string;
warehouseSku: string;
productNumber: string;
number: string;
skuName: string
warehouseSku: string
productNumber: string
number: string
locationName: string
}
......@@ -172,17 +171,17 @@ export function factoryWarehouseInfoPrint(data: PrintData) {
)
}
export function importWarehouseLocation(data:FormData) {
export function importWarehouseLocation(data: FormData) {
return axios.post<never, BaseRespData<never[]>>(
'/factoryWarehouseLocation/importWarehouseLocation',
data
data,
)
}
export function factoryWarehouseInventoryPrint(data:PrintData) {
export function factoryWarehouseInventoryPrint(data: PrintData) {
return axios.post<never, BaseRespData<never[]>>(
'/factoryWarehouseInventory/print',
data
data,
)
}
......@@ -275,16 +274,16 @@ export function warehouseInRecordListPageApi(
)
}
export function rejectInRecordApi({
ids,
list,
rejectReason,
}: {
ids: string
list: WarehouseParams[]
rejectReason: string
}) {
return axios.post<never, BaseRespData<never>>(
'factory/warehouseInRecord/turnDown',
'factory/warehouseInRecord/reject',
{
ids,
list,
rejectReason,
},
)
......@@ -297,7 +296,12 @@ export function addInRecordApi(form: InterWarehouseDetail) {
},
)
}
export function exportOrder(ids: number[], status: string | number) {
return axios.post<never, BaseRespData<never>>(
'factory/warehouseInRecord/exportData',
{ ids: ids, status },
)
}
export function updateInRecordApi(form: InterWarehouseDetail) {
return axios.post<never, BaseRespData<never>>(
'factory/warehouseInRecord/update',
......
// 允许通用对象类型
export type AnyObject = { [key: string]: unknown }
type IdType = string | number
function itemIsArray(obj: AnyObject): boolean {
for (const key in obj) {
if (Array.isArray(obj[key])) {
return true
}
}
return false
}
function isChange(arr: AnyObject[], arr1: AnyObject[]): boolean {
if (!arr1) return true
if (arr.length !== arr1.length) return true
for (const iterator of arr) {
const item = arr1.find((item: AnyObject) => item.id === iterator.id)
if (!item) return true
}
return false
}
export function checkUpdateParams(
newParams: AnyObject,
oldParams: AnyObject,
id: string = 'id',
other: Record<string, string> = {},
bool: boolean = false
): AnyObject | null {
oldParams = JSON.parse(JSON.stringify(oldParams))
if (!oldParams) return newParams
if ((newParams as { id?: unknown })?.id !== (oldParams as { id?: unknown })?.id) return newParams
const params: AnyObject = {
id: (newParams as { id?: unknown }).id
}
for (const key in newParams) {
if (typeof newParams[key] === 'object') {
if (Array.isArray(newParams[key])) {
const arr: AnyObject[] = newParams[key] as AnyObject[]
const arr1: AnyObject[] = (oldParams[key] as AnyObject[]) || []
const addList: AnyObject[] = []
const updateList: AnyObject[] = []
let removeList: IdType[] = []
const list: AnyObject[] = []
const keyname: string = other[key] || id
for (const iterator of arr) {
const obj: AnyObject = {}
const index = arr1.findIndex((item: AnyObject) => item[keyname] === iterator[keyname])
const isArray = itemIsArray(iterator)
if (index !== -1) {
const item = arr1[index]
arr1.splice(index, 1)
for (const key1 in iterator) {
if (key1 === keyname) continue
if (Array.isArray(iterator[key1])) {
if (isChange(iterator[key1] as AnyObject[], item[key1] as AnyObject[])) {
obj[key1] = iterator[key1]
}
} else if (iterator[key1] !== item[key1]) {
obj[key1] = iterator[key1]
}
}
if (Object.keys(obj).length > 0) {
if (isArray && !bool) {
list.push({
[keyname]: iterator[keyname],
...obj,
id: item.id
})
} else {
updateList.push({
[keyname]: iterator[keyname],
...obj,
id: item.id
})
}
}
} else {
if (isArray && !bool) {
list.push(iterator)
} else {
addList.push(iterator)
}
}
}
if (arr1.length > 0) {
removeList = arr1.map((item: AnyObject) => item['id'] as IdType)
}
const key_name = key.replace('List', 'Change')
params[key_name] = {}
if (addList.length > 0) {
(params[key_name] as AnyObject).addList = addList
}
if (updateList.length > 0) {
(params[key_name] as AnyObject).updateList = updateList
}
if (removeList.length > 0) {
(params[key_name] as AnyObject).removeList = removeList
}
if (list.length > 0) {
params[key_name] = list
}
if (Object.keys(params[key_name] as object).length === 0) {
delete params[key_name]
}
}
} else {
// 基础信息
// if (newParams[key] !== oldParams[key]) {
params[key] = newParams[key]
// }
}
}
if (Object.keys(params).length === 1) {
return null
}
return params
}
\ No newline at end of file
......@@ -126,8 +126,8 @@
删除
</el-button>
<el-button type="success" @click="handleExport"> 导出 </el-button>
<el-button type="primary" @click="getPrintData">
打印SKU标签
<el-button type="primary" @click="printProductTag">
打印商品SKU标签
</el-button>
<el-button
v-if="nodeCode === 'PENDING_AUDIT'"
......@@ -575,6 +575,7 @@
placeholder="请输入库位"
style="width: 120px"
filterable
@change="handleLocationChange(row.locationId, row)"
>
<ElOption
v-for="item in locationList"
......@@ -744,6 +745,50 @@
</span>
</template>
</ElDialog>
<el-dialog v-model="showPrintDialog" title="打印参数设置">
<el-table height="400px" :data="selections" border>
<el-table-column
width="60"
align="center"
type="index"
label="序号"
></el-table-column>
<el-table-column
align="center"
prop="skuName"
label="商品名称"
></el-table-column>
<el-table-column
align="center"
prop="warehouseSku"
label="商品SKU"
></el-table-column>
<el-table-column
align="center"
prop="locationCode"
label="库位编码"
></el-table-column>
<el-table-column
align="center"
prop="productNumber"
label="货号 "
></el-table-column>
<el-table-column align="center" prop="number" label="打印数量">
<template #default="{ row }">
<el-input
v-model="row.number"
oninput="value=value.replace(/[^\-?\d.]/g,'')"
placeholder="打印数量"
clearable
></el-input>
</template>
</el-table-column>
</el-table>
<template #footer>
<el-button @click="showPrintDialog = false">取消</el-button>
<el-button type="primary" @click="handlePrintProductTag">打印</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
......@@ -752,6 +797,7 @@ import { CirclePlusFilled } from '@element-plus/icons-vue'
import splitDiv from '@/components/splitDiv/splitDiv.vue'
import { ElTable } from 'element-plus'
import usePageList from '@/utils/hooks/usePageList'
// import { checkUpdateParams } from '@/utils/hooks/commonUtil'
import { useValue } from '@/utils/hooks/useValue'
import {
getInRecordStatusTree,
......@@ -768,6 +814,8 @@ import {
rejectInRecordApi,
LogListData,
} from '@/api/warehouse'
// factoryWarehouseInventoryPrint,
// import { filePath } from '@/api/axios.ts'
import BigNumber from 'bignumber.js'
import { ref, onMounted, watch, nextTick } from 'vue'
import 'element-plus/dist/index.css'
......@@ -966,11 +1014,38 @@ const getTreeNum = async () => {
console.error(e)
}
}
const getPrintData = () => {
if (selections.value.length === 0) {
return ElMessage.warning('请选择要操作的数据')
const showPrintDialog = ref(false)
const printProductTag = async () => {
if (!selections.value.length) {
return ElMessage.warning('请选择要删除的数据')
}
showPrintDialog.value = true
// selections.value.forEach((el:InterWarehousePage) => {
// el.number = ''
// })
}
async function handlePrintProductTag() {
// const flag = selections.value.every((el:InterWarehousePage) => el.number && el.number != '0')
// if (!flag) {
// return ElMessage.warning('打印数量需大于0')
// }
// const list = selections.value.map((item:InterWarehousePage) => {
// return {
// skuName: item.skuName,
// warehouseSku: item.warehouseSku,
// supplierItemNo: item.productNumber,
// number: item.number,
// locationName: item.locationCode,
// }
// })
// const res = await factoryWarehouseInventoryPrint({
// list,
// code: 'PT002',
// })
// showPrintDialog.value = false
// window.open(filePath + res.message, '_blank')
}
// 前端导入Excel
const excelFieldMap: Record<string, keyof InterProductList> = {
SKU图片: 'skuImage',
商品SKU: 'warehouseSku',
......@@ -1109,6 +1184,15 @@ const submitExportForm = () => {
// .finally(() => {
// loading.close()
// })
// try {
// const res = await exportOrder({
// ids: selection.value.map((el) => el.id),
// status: statusCode.value,
// })
// window.open(filePath + res.message)
// } catch (e) {
// // showError(e)
// }
}
const getWarehouseList = async () => {
try {
......@@ -1147,7 +1231,7 @@ const skudblclick = (val: InterskuList) => {
sku = '',
skuName = '',
image = '',
locationId = 0,
locationId = null,
} = val || {}
otherPurchaseData.value = [
...otherPurchaseData.value,
......@@ -1157,7 +1241,7 @@ const skudblclick = (val: InterskuList) => {
skuName,
productNo,
locationCode: locationCode ?? '', // 确保空值处理
locationId: locationId ?? 0, // 确保空值处理
locationId: locationId ?? null, // 确保空值处理
costPrice: factoryPrice,
buyStored: null,
totalPrice: null,
......@@ -1220,11 +1304,13 @@ const addDialog = async (i: number, v: InterWarehousePage | null) => {
otherPurchaseData.value = []
formId.value = undefined
}
fetchLocationList('')
newDialogVisible.value = true
}
const getProduct = async (id: number | undefined) => {
try {
const res = await getWarehouseInRecordDetailApi(id)
editForm2.value = res.data
otherPurchaseData.value = res.data?.productList || []
} catch (e) {
console.error(e)
......@@ -1294,11 +1380,14 @@ const rejectedInRecord = () => {
inputErrorMessage: '请输入驳回原因',
inputPlaceholder: '驳回原因',
}).then(async ({ value }: { value: string }) => {
const ids = selections.value
.map((el: InterWarehousePage) => el.id)
.join(',')
const data = selections.value.map(
({ id, dataVersion }: InterWarehousePage) => ({
id,
dataVersion,
}),
)
try {
await rejectInRecordApi({ ids: ids, rejectReason: value })
await rejectInRecordApi({ list: data, rejectReason: value })
ElMessage.success('操作成功')
search()
await getTreeNum()
......@@ -1424,6 +1513,10 @@ const addSection = async () => {
const upSection = async () => {
const params = { ...editForm.value }
params.productList = otherPurchaseData.value
// const result = checkUpdateParams(params, editForm2.value, '', {
// productList: 'value',
// })
// console.log(result, params, editForm2.value)
try {
await updateInRecordApi(params)
newDialogVisible.value = false
......@@ -1520,12 +1613,12 @@ const fetchLocationList = async (query: string) => {
}
// 输入2秒后再调用接口(节流)
// const handleLocationSearch = debounce(fetchLocationList, 2000)
// const handleLocationChange = (val: number, row: InterProductList) => {
// const found = locationList.value.find(
// (item: InterProductList) => item.locationId === val,
// )
// row.locationCode = found ? found.locationCode : ''
// }
const handleLocationChange = (val: number, row: InterProductList) => {
const found = locationList.value.find(
(item: InterProductList) => item.locationId === val,
)
row.locationCode = found ? found.locationCode : ''
}
onMounted(() => {
getTreeNum()
getWarehouseList()
......
......@@ -575,6 +575,7 @@
placeholder="请输入库位"
style="width: 120px"
filterable
@change="handleLocationChange(row.locationId, row)"
>
<ElOption
v-for="item in locationList"
......@@ -796,6 +797,7 @@ import { CirclePlusFilled } from '@element-plus/icons-vue'
import splitDiv from '@/components/splitDiv/splitDiv.vue'
import { ElTable } from 'element-plus'
import usePageList from '@/utils/hooks/usePageList'
// import { checkUpdateParams } from '@/utils/hooks/commonUtil'
import { useValue } from '@/utils/hooks/useValue'
import {
getInRecordStatusTree,
......@@ -811,9 +813,9 @@ import {
getInRecordLogApi,
rejectInRecordApi,
LogListData,
factoryWarehouseInventoryPrint,
} from '@/api/warehouse'
import { filePath } from '@/api/axios.ts'
// factoryWarehouseInventoryPrint,
// import { filePath } from '@/api/axios.ts'
import BigNumber from 'bignumber.js'
import { ref, onMounted, watch, nextTick } from 'vue'
import 'element-plus/dist/index.css'
......@@ -1043,6 +1045,7 @@ async function handlePrintProductTag() {
// showPrintDialog.value = false
// window.open(filePath + res.message, '_blank')
}
// 前端导入Excel
const excelFieldMap: Record<string, keyof InterProductList> = {
SKU图片: 'skuImage',
商品SKU: 'warehouseSku',
......@@ -1181,6 +1184,15 @@ const submitExportForm = () => {
// .finally(() => {
// loading.close()
// })
// try {
// const res = await exportOrder({
// ids: selection.value.map((el) => el.id),
// status: statusCode.value,
// })
// window.open(filePath + res.message)
// } catch (e) {
// // showError(e)
// }
}
const getWarehouseList = async () => {
try {
......@@ -1219,7 +1231,7 @@ const skudblclick = (val: InterskuList) => {
sku = '',
skuName = '',
image = '',
locationId = 0,
locationId = null,
} = val || {}
otherPurchaseData.value = [
...otherPurchaseData.value,
......@@ -1229,7 +1241,7 @@ const skudblclick = (val: InterskuList) => {
skuName,
productNo,
locationCode: locationCode ?? '', // 确保空值处理
locationId: locationId ?? 0, // 确保空值处理
locationId: locationId ?? null, // 确保空值处理
costPrice: factoryPrice,
buyStored: null,
totalPrice: null,
......@@ -1292,11 +1304,13 @@ const addDialog = async (i: number, v: InterWarehousePage | null) => {
otherPurchaseData.value = []
formId.value = undefined
}
fetchLocationList('')
newDialogVisible.value = true
}
const getProduct = async (id: number | undefined) => {
try {
const res = await getWarehouseInRecordDetailApi(id)
editForm2.value = res.data
otherPurchaseData.value = res.data?.productList || []
} catch (e) {
console.error(e)
......@@ -1366,11 +1380,14 @@ const rejectedInRecord = () => {
inputErrorMessage: '请输入驳回原因',
inputPlaceholder: '驳回原因',
}).then(async ({ value }: { value: string }) => {
const ids = selections.value
.map((el: InterWarehousePage) => el.id)
.join(',')
const data = selections.value.map(
({ id, dataVersion }: InterWarehousePage) => ({
id,
dataVersion,
}),
)
try {
await rejectInRecordApi({ ids: ids, rejectReason: value })
await rejectInRecordApi({ list: data, rejectReason: value })
ElMessage.success('操作成功')
search()
await getTreeNum()
......@@ -1496,6 +1513,10 @@ const addSection = async () => {
const upSection = async () => {
const params = { ...editForm.value }
params.productList = otherPurchaseData.value
// const result = checkUpdateParams(params, editForm2.value, '', {
// productList: 'value',
// })
// console.log(result, params, editForm2.value)
try {
await updateInRecordApi(params)
newDialogVisible.value = false
......@@ -1592,12 +1613,12 @@ const fetchLocationList = async (query: string) => {
}
// 输入2秒后再调用接口(节流)
// const handleLocationSearch = debounce(fetchLocationList, 2000)
// const handleLocationChange = (val: number, row: InterProductList) => {
// const found = locationList.value.find(
// (item: InterProductList) => item.locationId === val,
// )
// row.locationCode = found ? found.locationCode : ''
// }
const handleLocationChange = (val: number, row: InterProductList) => {
const found = locationList.value.find(
(item: InterProductList) => item.locationId === val,
)
row.locationCode = found ? found.locationCode : ''
}
onMounted(() => {
getTreeNum()
getWarehouseList()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment