Commit e0a84a01 by wuqian

入库单第一版

parent d0b4ff7e
...@@ -14,15 +14,15 @@ export interface LogListData { ...@@ -14,15 +14,15 @@ export interface LogListData {
description: string description: string
createdTime?: string | null createdTime?: string | null
} }
export interface PrintData{ export interface PrintData {
code:string code: string
list:{ list: {
locationName:string; locationName: string
pickingLocation?:string pickingLocation?: string
skuName?:string skuName?: string
warehouseSku?:string warehouseSku?: string
supplierItemNo?:string supplierItemNo?: string
number?:string number?: string
}[] }[]
} }
export interface factoryWarehouseInfo { export interface factoryWarehouseInfo {
...@@ -35,23 +35,22 @@ export interface factoryWarehouseInfo { ...@@ -35,23 +35,22 @@ export interface factoryWarehouseInfo {
} }
export interface WarehouseInventory { export interface WarehouseInventory {
pageSize: number; pageSize: number
currentPage: number; currentPage: number
total?: number; total?: number
warehouseId: string; warehouseId: string
skuName: string; skuName: string
warehouseSku: string; warehouseSku: string
occupyInventory: string; occupyInventory: string
inventoryStart: string; inventoryStart: string
inventoryEnd: string; inventoryEnd: string
productNumber: string; productNumber: string
freezeInventory: string; freezeInventory: string
inventory: string; inventory: string
usableInventoryStart: string; usableInventoryStart: string
usableInventoryEnd: string; usableInventoryEnd: string
occupyInventoryEnd: string; occupyInventoryEnd: string
occupyInventoryStart: string; occupyInventoryStart: string
} }
export interface UpdateDefaulted { export interface UpdateDefaulted {
...@@ -78,10 +77,10 @@ export interface warehouseInfo { ...@@ -78,10 +77,10 @@ export interface warehouseInfo {
export interface WarehouseWarning { export interface WarehouseWarning {
id: number | string id: number | string
locationCode: string locationCode: string
skuName: string; skuName: string
warehouseSku: string; warehouseSku: string
productNumber: string; productNumber: string
number: string; number: string
locationName: string locationName: string
} }
...@@ -172,17 +171,17 @@ export function factoryWarehouseInfoPrint(data: PrintData) { ...@@ -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[]>>( return axios.post<never, BaseRespData<never[]>>(
'/factoryWarehouseLocation/importWarehouseLocation', '/factoryWarehouseLocation/importWarehouseLocation',
data data,
) )
} }
export function factoryWarehouseInventoryPrint(data:PrintData) { export function factoryWarehouseInventoryPrint(data: PrintData) {
return axios.post<never, BaseRespData<never[]>>( return axios.post<never, BaseRespData<never[]>>(
'/factoryWarehouseInventory/print', '/factoryWarehouseInventory/print',
data data,
) )
} }
...@@ -275,16 +274,16 @@ export function warehouseInRecordListPageApi( ...@@ -275,16 +274,16 @@ export function warehouseInRecordListPageApi(
) )
} }
export function rejectInRecordApi({ export function rejectInRecordApi({
ids, list,
rejectReason, rejectReason,
}: { }: {
ids: string list: WarehouseParams[]
rejectReason: string rejectReason: string
}) { }) {
return axios.post<never, BaseRespData<never>>( return axios.post<never, BaseRespData<never>>(
'factory/warehouseInRecord/turnDown', 'factory/warehouseInRecord/reject',
{ {
ids, list,
rejectReason, rejectReason,
}, },
) )
...@@ -297,7 +296,12 @@ export function addInRecordApi(form: InterWarehouseDetail) { ...@@ -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) { export function updateInRecordApi(form: InterWarehouseDetail) {
return axios.post<never, BaseRespData<never>>( return axios.post<never, BaseRespData<never>>(
'factory/warehouseInRecord/update', '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 @@ ...@@ -126,8 +126,8 @@
删除 删除
</el-button> </el-button>
<el-button type="success" @click="handleExport"> 导出 </el-button> <el-button type="success" @click="handleExport"> 导出 </el-button>
<el-button type="primary" @click="getPrintData"> <el-button type="primary" @click="printProductTag">
打印SKU标签 打印商品SKU标签
</el-button> </el-button>
<el-button <el-button
v-if="nodeCode === 'PENDING_AUDIT'" v-if="nodeCode === 'PENDING_AUDIT'"
...@@ -575,6 +575,7 @@ ...@@ -575,6 +575,7 @@
placeholder="请输入库位" placeholder="请输入库位"
style="width: 120px" style="width: 120px"
filterable filterable
@change="handleLocationChange(row.locationId, row)"
> >
<ElOption <ElOption
v-for="item in locationList" v-for="item in locationList"
...@@ -744,6 +745,50 @@ ...@@ -744,6 +745,50 @@
</span> </span>
</template> </template>
</ElDialog> </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> </template>
<script setup lang="ts"> <script setup lang="ts">
...@@ -752,6 +797,7 @@ import { CirclePlusFilled } from '@element-plus/icons-vue' ...@@ -752,6 +797,7 @@ import { CirclePlusFilled } from '@element-plus/icons-vue'
import splitDiv from '@/components/splitDiv/splitDiv.vue' import splitDiv from '@/components/splitDiv/splitDiv.vue'
import { ElTable } from 'element-plus' import { ElTable } from 'element-plus'
import usePageList from '@/utils/hooks/usePageList' import usePageList from '@/utils/hooks/usePageList'
// import { checkUpdateParams } from '@/utils/hooks/commonUtil'
import { useValue } from '@/utils/hooks/useValue' import { useValue } from '@/utils/hooks/useValue'
import { import {
getInRecordStatusTree, getInRecordStatusTree,
...@@ -768,6 +814,8 @@ import { ...@@ -768,6 +814,8 @@ import {
rejectInRecordApi, rejectInRecordApi,
LogListData, LogListData,
} from '@/api/warehouse' } from '@/api/warehouse'
// factoryWarehouseInventoryPrint,
// import { filePath } from '@/api/axios.ts'
import BigNumber from 'bignumber.js' import BigNumber from 'bignumber.js'
import { ref, onMounted, watch, nextTick } from 'vue' import { ref, onMounted, watch, nextTick } from 'vue'
import 'element-plus/dist/index.css' import 'element-plus/dist/index.css'
...@@ -966,11 +1014,38 @@ const getTreeNum = async () => { ...@@ -966,11 +1014,38 @@ const getTreeNum = async () => {
console.error(e) console.error(e)
} }
} }
const getPrintData = () => { const showPrintDialog = ref(false)
if (selections.value.length === 0) { const printProductTag = async () => {
return ElMessage.warning('请选择要操作的数据') 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> = { const excelFieldMap: Record<string, keyof InterProductList> = {
SKU图片: 'skuImage', SKU图片: 'skuImage',
商品SKU: 'warehouseSku', 商品SKU: 'warehouseSku',
...@@ -1109,6 +1184,15 @@ const submitExportForm = () => { ...@@ -1109,6 +1184,15 @@ const submitExportForm = () => {
// .finally(() => { // .finally(() => {
// loading.close() // 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 () => { const getWarehouseList = async () => {
try { try {
...@@ -1147,7 +1231,7 @@ const skudblclick = (val: InterskuList) => { ...@@ -1147,7 +1231,7 @@ const skudblclick = (val: InterskuList) => {
sku = '', sku = '',
skuName = '', skuName = '',
image = '', image = '',
locationId = 0, locationId = null,
} = val || {} } = val || {}
otherPurchaseData.value = [ otherPurchaseData.value = [
...otherPurchaseData.value, ...otherPurchaseData.value,
...@@ -1157,7 +1241,7 @@ const skudblclick = (val: InterskuList) => { ...@@ -1157,7 +1241,7 @@ const skudblclick = (val: InterskuList) => {
skuName, skuName,
productNo, productNo,
locationCode: locationCode ?? '', // 确保空值处理 locationCode: locationCode ?? '', // 确保空值处理
locationId: locationId ?? 0, // 确保空值处理 locationId: locationId ?? null, // 确保空值处理
costPrice: factoryPrice, costPrice: factoryPrice,
buyStored: null, buyStored: null,
totalPrice: null, totalPrice: null,
...@@ -1220,11 +1304,13 @@ const addDialog = async (i: number, v: InterWarehousePage | null) => { ...@@ -1220,11 +1304,13 @@ const addDialog = async (i: number, v: InterWarehousePage | null) => {
otherPurchaseData.value = [] otherPurchaseData.value = []
formId.value = undefined formId.value = undefined
} }
fetchLocationList('')
newDialogVisible.value = true newDialogVisible.value = true
} }
const getProduct = async (id: number | undefined) => { const getProduct = async (id: number | undefined) => {
try { try {
const res = await getWarehouseInRecordDetailApi(id) const res = await getWarehouseInRecordDetailApi(id)
editForm2.value = res.data
otherPurchaseData.value = res.data?.productList || [] otherPurchaseData.value = res.data?.productList || []
} catch (e) { } catch (e) {
console.error(e) console.error(e)
...@@ -1294,11 +1380,14 @@ const rejectedInRecord = () => { ...@@ -1294,11 +1380,14 @@ const rejectedInRecord = () => {
inputErrorMessage: '请输入驳回原因', inputErrorMessage: '请输入驳回原因',
inputPlaceholder: '驳回原因', inputPlaceholder: '驳回原因',
}).then(async ({ value }: { value: string }) => { }).then(async ({ value }: { value: string }) => {
const ids = selections.value const data = selections.value.map(
.map((el: InterWarehousePage) => el.id) ({ id, dataVersion }: InterWarehousePage) => ({
.join(',') id,
dataVersion,
}),
)
try { try {
await rejectInRecordApi({ ids: ids, rejectReason: value }) await rejectInRecordApi({ list: data, rejectReason: value })
ElMessage.success('操作成功') ElMessage.success('操作成功')
search() search()
await getTreeNum() await getTreeNum()
...@@ -1424,6 +1513,10 @@ const addSection = async () => { ...@@ -1424,6 +1513,10 @@ const addSection = async () => {
const upSection = async () => { const upSection = async () => {
const params = { ...editForm.value } const params = { ...editForm.value }
params.productList = otherPurchaseData.value params.productList = otherPurchaseData.value
// const result = checkUpdateParams(params, editForm2.value, '', {
// productList: 'value',
// })
// console.log(result, params, editForm2.value)
try { try {
await updateInRecordApi(params) await updateInRecordApi(params)
newDialogVisible.value = false newDialogVisible.value = false
...@@ -1520,12 +1613,12 @@ const fetchLocationList = async (query: string) => { ...@@ -1520,12 +1613,12 @@ const fetchLocationList = async (query: string) => {
} }
// 输入2秒后再调用接口(节流) // 输入2秒后再调用接口(节流)
// const handleLocationSearch = debounce(fetchLocationList, 2000) // const handleLocationSearch = debounce(fetchLocationList, 2000)
// const handleLocationChange = (val: number, row: InterProductList) => { const handleLocationChange = (val: number, row: InterProductList) => {
// const found = locationList.value.find( const found = locationList.value.find(
// (item: InterProductList) => item.locationId === val, (item: InterProductList) => item.locationId === val,
// ) )
// row.locationCode = found ? found.locationCode : '' row.locationCode = found ? found.locationCode : ''
// } }
onMounted(() => { onMounted(() => {
getTreeNum() getTreeNum()
getWarehouseList() getWarehouseList()
......
...@@ -575,6 +575,7 @@ ...@@ -575,6 +575,7 @@
placeholder="请输入库位" placeholder="请输入库位"
style="width: 120px" style="width: 120px"
filterable filterable
@change="handleLocationChange(row.locationId, row)"
> >
<ElOption <ElOption
v-for="item in locationList" v-for="item in locationList"
...@@ -796,6 +797,7 @@ import { CirclePlusFilled } from '@element-plus/icons-vue' ...@@ -796,6 +797,7 @@ import { CirclePlusFilled } from '@element-plus/icons-vue'
import splitDiv from '@/components/splitDiv/splitDiv.vue' import splitDiv from '@/components/splitDiv/splitDiv.vue'
import { ElTable } from 'element-plus' import { ElTable } from 'element-plus'
import usePageList from '@/utils/hooks/usePageList' import usePageList from '@/utils/hooks/usePageList'
// import { checkUpdateParams } from '@/utils/hooks/commonUtil'
import { useValue } from '@/utils/hooks/useValue' import { useValue } from '@/utils/hooks/useValue'
import { import {
getInRecordStatusTree, getInRecordStatusTree,
...@@ -811,9 +813,9 @@ import { ...@@ -811,9 +813,9 @@ import {
getInRecordLogApi, getInRecordLogApi,
rejectInRecordApi, rejectInRecordApi,
LogListData, LogListData,
factoryWarehouseInventoryPrint,
} from '@/api/warehouse' } from '@/api/warehouse'
import { filePath } from '@/api/axios.ts' // factoryWarehouseInventoryPrint,
// import { filePath } from '@/api/axios.ts'
import BigNumber from 'bignumber.js' import BigNumber from 'bignumber.js'
import { ref, onMounted, watch, nextTick } from 'vue' import { ref, onMounted, watch, nextTick } from 'vue'
import 'element-plus/dist/index.css' import 'element-plus/dist/index.css'
...@@ -1043,6 +1045,7 @@ async function handlePrintProductTag() { ...@@ -1043,6 +1045,7 @@ async function handlePrintProductTag() {
// showPrintDialog.value = false // showPrintDialog.value = false
// window.open(filePath + res.message, '_blank') // window.open(filePath + res.message, '_blank')
} }
// 前端导入Excel
const excelFieldMap: Record<string, keyof InterProductList> = { const excelFieldMap: Record<string, keyof InterProductList> = {
SKU图片: 'skuImage', SKU图片: 'skuImage',
商品SKU: 'warehouseSku', 商品SKU: 'warehouseSku',
...@@ -1181,6 +1184,15 @@ const submitExportForm = () => { ...@@ -1181,6 +1184,15 @@ const submitExportForm = () => {
// .finally(() => { // .finally(() => {
// loading.close() // 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 () => { const getWarehouseList = async () => {
try { try {
...@@ -1219,7 +1231,7 @@ const skudblclick = (val: InterskuList) => { ...@@ -1219,7 +1231,7 @@ const skudblclick = (val: InterskuList) => {
sku = '', sku = '',
skuName = '', skuName = '',
image = '', image = '',
locationId = 0, locationId = null,
} = val || {} } = val || {}
otherPurchaseData.value = [ otherPurchaseData.value = [
...otherPurchaseData.value, ...otherPurchaseData.value,
...@@ -1229,7 +1241,7 @@ const skudblclick = (val: InterskuList) => { ...@@ -1229,7 +1241,7 @@ const skudblclick = (val: InterskuList) => {
skuName, skuName,
productNo, productNo,
locationCode: locationCode ?? '', // 确保空值处理 locationCode: locationCode ?? '', // 确保空值处理
locationId: locationId ?? 0, // 确保空值处理 locationId: locationId ?? null, // 确保空值处理
costPrice: factoryPrice, costPrice: factoryPrice,
buyStored: null, buyStored: null,
totalPrice: null, totalPrice: null,
...@@ -1292,11 +1304,13 @@ const addDialog = async (i: number, v: InterWarehousePage | null) => { ...@@ -1292,11 +1304,13 @@ const addDialog = async (i: number, v: InterWarehousePage | null) => {
otherPurchaseData.value = [] otherPurchaseData.value = []
formId.value = undefined formId.value = undefined
} }
fetchLocationList('')
newDialogVisible.value = true newDialogVisible.value = true
} }
const getProduct = async (id: number | undefined) => { const getProduct = async (id: number | undefined) => {
try { try {
const res = await getWarehouseInRecordDetailApi(id) const res = await getWarehouseInRecordDetailApi(id)
editForm2.value = res.data
otherPurchaseData.value = res.data?.productList || [] otherPurchaseData.value = res.data?.productList || []
} catch (e) { } catch (e) {
console.error(e) console.error(e)
...@@ -1366,11 +1380,14 @@ const rejectedInRecord = () => { ...@@ -1366,11 +1380,14 @@ const rejectedInRecord = () => {
inputErrorMessage: '请输入驳回原因', inputErrorMessage: '请输入驳回原因',
inputPlaceholder: '驳回原因', inputPlaceholder: '驳回原因',
}).then(async ({ value }: { value: string }) => { }).then(async ({ value }: { value: string }) => {
const ids = selections.value const data = selections.value.map(
.map((el: InterWarehousePage) => el.id) ({ id, dataVersion }: InterWarehousePage) => ({
.join(',') id,
dataVersion,
}),
)
try { try {
await rejectInRecordApi({ ids: ids, rejectReason: value }) await rejectInRecordApi({ list: data, rejectReason: value })
ElMessage.success('操作成功') ElMessage.success('操作成功')
search() search()
await getTreeNum() await getTreeNum()
...@@ -1496,6 +1513,10 @@ const addSection = async () => { ...@@ -1496,6 +1513,10 @@ const addSection = async () => {
const upSection = async () => { const upSection = async () => {
const params = { ...editForm.value } const params = { ...editForm.value }
params.productList = otherPurchaseData.value params.productList = otherPurchaseData.value
// const result = checkUpdateParams(params, editForm2.value, '', {
// productList: 'value',
// })
// console.log(result, params, editForm2.value)
try { try {
await updateInRecordApi(params) await updateInRecordApi(params)
newDialogVisible.value = false newDialogVisible.value = false
...@@ -1592,12 +1613,12 @@ const fetchLocationList = async (query: string) => { ...@@ -1592,12 +1613,12 @@ const fetchLocationList = async (query: string) => {
} }
// 输入2秒后再调用接口(节流) // 输入2秒后再调用接口(节流)
// const handleLocationSearch = debounce(fetchLocationList, 2000) // const handleLocationSearch = debounce(fetchLocationList, 2000)
// const handleLocationChange = (val: number, row: InterProductList) => { const handleLocationChange = (val: number, row: InterProductList) => {
// const found = locationList.value.find( const found = locationList.value.find(
// (item: InterProductList) => item.locationId === val, (item: InterProductList) => item.locationId === val,
// ) )
// row.locationCode = found ? found.locationCode : '' row.locationCode = found ? found.locationCode : ''
// } }
onMounted(() => { onMounted(() => {
getTreeNum() getTreeNum()
getWarehouseList() 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