Commit f7e76d29 by wuqian

修改库位

parent fe950f45
......@@ -9,7 +9,7 @@ import {
ILocation,
AnyObject,
InterProductList,
ExportInWarehouseInfo
ExportInWarehouseInfo,
} from '@/types/api/warehouse'
export interface LogListData {
createTime: string
......@@ -60,7 +60,10 @@ export interface factoryWarehouseInfo {
remark?: string
idList?: string | number[]
}
export interface factoryLocation {
locationId?: string
idList?: string | number[]
}
export interface ExportFactoryWarehouseInfo {
pageSize?: number
currentPage?: number
......@@ -120,6 +123,7 @@ export interface WarehouseWarning {
productNumber: string
number: string
locationName: string
warehouseId: string | number
}
export interface positionInfo {
......@@ -143,7 +147,12 @@ export interface positionFormInfo {
remark: string
status: number
}
export interface loactionData {
id?: number
warehouseId?: number | string
warehouseName?: string
locationCode?: number | string
}
interface WarehouseWarningData {
id: number
factoryId: number
......@@ -173,6 +182,12 @@ export function getFactoryLocation(data: factoryWarehouseInfo) {
data,
)
}
export function updateLocationApi(data: factoryLocation) {
return axios.post<never, BasePaginationData<never>>(
'factoryWarehouseInventory/updateLocation',
data,
)
}
export function exportWarehouseInfo(data: ExportFactoryWarehouseInfo) {
return axios.post<never, BasePaginationData<positionInfo>>(
'factoryWarehouseInventory/inventory',
......@@ -240,6 +255,14 @@ export function warehouseInfoGetAll() {
'/factoryWarehouseInfo/getAll',
)
}
export function LocationInfoGetAll(wareHouseId?: string | number) {
return axios.get<never, BaseRespData<loactionData[]>>(
'/factoryWarehouseLocation/getByWareHouse',
{
params: { wareHouseId },
},
)
}
export function createWarehouseInventoryApi(data: WarehouseWarningData) {
return axios.post<never, BaseRespData<never>>(
......
......@@ -1156,7 +1156,7 @@ const excelFieldMap: Record<string, keyof InterProductList> = {
入库数量: 'buyStored',
// '成本价(¥)': 'costPrice',
// '总成本(¥)': 'totalPrice',
// 库位: 'locationCode',
库位: 'locationCode',
备注: 'remark',
}
......@@ -1201,6 +1201,7 @@ const handleLocalImport = async ({
return obj
})
.filter((item) => item.warehouseSku)
// console.log('@', importedData, data)
if (importedData.length === 0) {
ElMessage.warning('导入数据中没有有效的商品SKU')
importDialogVisible.value = false
......@@ -1222,13 +1223,18 @@ const handleLocalImport = async ({
const importedItem = importedData.find(
(item) => item.warehouseSku === skuItem.sku,
)
// console.log(skuItem,'importedItem', importedItem)
const target = locationList.value.find((item) => {
return item.locationCode == importedItem?.locationCode
})
// console.log(importedItem, '11111@', locationList.value, target)
return {
skuImage: skuItem.image,
warehouseSku: skuItem.sku,
skuName: skuItem.skuName,
productNo: skuItem.productNo,
locationCode: skuItem.locationCode ?? '',
locationId: skuItem.locationId ?? null,
locationId: skuItem.locationId || target?.locationId,
costPrice: skuItem.factoryPrice,
buyStored: importedItem?.buyStored ?? null,
totalPrice: new BigNumber(
......@@ -1535,6 +1541,7 @@ const addOtherCurrency = async () => {
ElMessage.error('请至少选择一条数据')
return
}
for (let i = 0; i < arr.length; i++) {
if (!arr[i].buyStored) {
ElMessage.error('请输入入库数量')
......@@ -1544,6 +1551,12 @@ const addOtherCurrency = async () => {
ElMessage.error('请选择库位')
return
}
const found = locationList.value.find(
(item: InterProductList) => item.locationId === arr[i].locationId,
)
if (!arr[i].locationCode) {
arr[i].locationCode =found? found?.locationCode:''
}
}
if (!formId.value) {
addSection()
......@@ -1554,7 +1567,7 @@ const addOtherCurrency = async () => {
const filterSkuData = computed(() => {
const skuList = otherPurchaseData.value.map((el) => el.warehouseSku)
console.log(skuList, skuData.value)
// console.log(skuList, skuData.value)
return skuData.value.filter((el) => !skuList.includes(el.sku))
})
const addSection = async () => {
......
......@@ -3,15 +3,18 @@ import {
factoryWarehouseInfo,
warehouseInfo,
warehouseInfoGetAll,
updateLocationApi,
LocationInfoGetAll,
getWarehouseInventoryInfo,
factoryLogWarehouseLog,
LogListData,
WarehouseWarning,
factoryWarehouseInventoryPrint,
exportWarehouseInfo,
loactionData
} from '@/api/warehouse.ts'
import { AnyObject } from '@/types/api/warehouse'
import { ref } from 'vue'
import { ref, computed } from 'vue'
import SplitDiv from '@/components/splitDiv/splitDiv.vue'
import { filePath } from '@/api/axios.ts'
......@@ -39,6 +42,40 @@ const pagination = ref<factoryWarehouseInfo>({
currentPage: 1,
total: 0,
})
const isSameWarehouse = computed(() => {
if (selections.value.length === 0) return false
const firstId = selections.value[0]?.warehouseId
return selections.value.every(
(item: WarehouseWarning) => item.warehouseId === firstId,
)
})
const modifyLocationDialog = ref(false)
const locationForm = ref({
warehouseId: '',
})
const submitLocationForm = async () => {
if (locationForm.value.warehouseId) {
const idList = selections.value.map((el: WarehouseWarning) => Number(el.id))
const res = await updateLocationApi({
idList: idList,
locationId: locationForm.value.warehouseId,
})
if (res.code == 200) {
modifyLocationDialog.value = false
ElMessage.success('修改成功')
getData()
}
} else {
ElMessage.warning('请选择库位')
}
}
const LocationList = ref<loactionData[]>([])
const modifyStorageLocation = async () => {
locationForm.value.warehouseId = ''
modifyLocationDialog.value = true
const { data } = await LocationInfoGetAll(selections.value[0]?.warehouseId)
LocationList.value = data
}
const showPrintDialog = ref(false)
const exportLoading = ref(false)
const clickItem = (row: WarehouseWarning) => {
......@@ -327,6 +364,14 @@ getWarehouse()
>导出</el-button
>
</el-form-item>
<el-form-item style="margin-top: 5px">
<el-button
type="warning"
:disabled="!isSameWarehouse"
@click="modifyStorageLocation"
>修改库位</el-button
>
</el-form-item>
</el-form>
</el-card>
</template>
......@@ -497,6 +542,36 @@ getWarehouse()
</span>
</template>
</ElDialog>
<ElDialog
v-model="modifyLocationDialog"
title="修改库位"
width="500px"
:close-on-click-modal="false"
>
<el-form :model="locationForm" label-width="80px">
<el-form-item label="选择库位" prop="warehouseId">
<el-select
v-model="locationForm.warehouseId"
clearable
filterable
placeholder="请选择库位"
>
<el-option
v-for="item in LocationList"
:key="item.id"
:label="item.locationCode"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="modifyLocationDialog = false">取消</el-button>
<el-button type="primary" @click="submitLocationForm">确认</el-button>
</span>
</template>
</ElDialog>
</template>
<style scoped lang="scss">
......
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