Commit a3d08541 by qinjianhui

Merge branch 'fix_1001087' into 'dev'

fix:【工厂端】【仓库-入库单】:保存入库单生成三个一样的数据,作废重复数据提示报错#1001087

See merge request !170
parents 2c407920 5df48561
...@@ -308,7 +308,11 @@ ...@@ -308,7 +308,11 @@
</div> </div>
</template> </template>
<template #bottom> <template #bottom>
<el-tabs v-loading="showDetailLoading" v-model="tabsValue" @tab-click="tabsClick"> <el-tabs
v-loading="showDetailLoading"
v-model="tabsValue"
@tab-click="tabsClick"
>
<el-tab-pane name="0" label="入库商品"> <el-tab-pane name="0" label="入库商品">
<div class="table-wrap"> <div class="table-wrap">
<ElTable size="small" :data="detailList" height="100%" border> <ElTable size="small" :data="detailList" height="100%" border>
...@@ -341,7 +345,6 @@ ...@@ -341,7 +345,6 @@
width="180" width="180"
prop="warehouseSku" prop="warehouseSku"
> >
</ElTableColumn> </ElTableColumn>
<ElTableColumn <ElTableColumn
...@@ -467,8 +470,13 @@ ...@@ -467,8 +470,13 @@
<div class="import-dialog"> <div class="import-dialog">
<div class="label" style="margin-bottom: 10px"> <div class="label" style="margin-bottom: 10px">
<span style="margin-right: 10px">所属客户:</span> <span style="margin-right: 10px">所属客户:</span>
<el-select v-model="importUserMark" size="small" style="width: 100px;"> <el-select v-model="importUserMark" size="small" style="width: 100px">
<el-option v-for="user in userMarkList" :key="user.userId" :label="user.userMark" :value="user.userId"></el-option> <el-option
v-for="user in userMarkList"
:key="user.userId"
:label="user.userMark"
:value="user.userId"
></el-option>
</el-select> </el-select>
</div> </div>
<div class="import-content"> <div class="import-content">
...@@ -651,10 +659,17 @@ ...@@ -651,10 +659,17 @@
</div> </div>
<template #footer> <template #footer>
<div class="product-dialog-footer"> <div class="product-dialog-footer">
<div style="display: flex;align-items: center"> <div style="display: flex; align-items: center">
<span style="margin-right: 10px;font-style:13px;color: gray">搜索:</span> <span style="margin-right: 10px; font-style: 13px; color: gray"
<el-select v-model="userMark" size="small" style="width: 100px;"> >搜索:</span
<el-option v-for="user in userMarkList" :key="user.userId" :label="user.userMark" :value="user.userId"></el-option> >
<el-select v-model="userMark" size="small" style="width: 100px">
<el-option
v-for="user in userMarkList"
:key="user.userId"
:label="user.userMark"
:value="user.userId"
></el-option>
</el-select> </el-select>
<el-input <el-input
v-model.trim="selectSku" v-model.trim="selectSku"
...@@ -873,8 +888,13 @@ ...@@ -873,8 +888,13 @@
> >
<div class="label" style="margin-bottom: 10px"> <div class="label" style="margin-bottom: 10px">
<span style="margin-right: 10px">所属客户:</span> <span style="margin-right: 10px">所属客户:</span>
<el-select v-model="batchUserMark" size="small" style="width: 100px;"> <el-select v-model="batchUserMark" size="small" style="width: 100px">
<el-option v-for="user in userMarkList" :key="user.userId" :label="user.userMark" :value="user.userId"></el-option> <el-option
v-for="user in userMarkList"
:key="user.userId"
:label="user.userMark"
:value="user.userId"
></el-option>
</el-select> </el-select>
</div> </div>
<div> <div>
...@@ -922,7 +942,9 @@ import { ...@@ -922,7 +942,9 @@ import {
warehouseInfo, warehouseInfo,
InRecordBatchCheckPrintApi, InRecordBatchCheckPrintApi,
factoryWarehouseInventoryPrint, factoryWarehouseInventoryPrint,
warehouseInRecordExport, getLocalFactoryList, getBySkuAndUserMarkApi, warehouseInRecordExport,
getLocalFactoryList,
getBySkuAndUserMarkApi,
} from '@/api/warehouse' } from '@/api/warehouse'
import { filePath } from '@/api/axios.ts' import { filePath } from '@/api/axios.ts'
import BigNumber from 'bignumber.js' import BigNumber from 'bignumber.js'
...@@ -940,7 +962,7 @@ import { ...@@ -940,7 +962,7 @@ import {
import ImageView from '@/components/ImageView.vue' import ImageView from '@/components/ImageView.vue'
import UploadExcel from '@/components/UploadExcel.vue' import UploadExcel from '@/components/UploadExcel.vue'
import { useEnterKeyTrigger } from '@/utils/hooks/useEnterKeyTrigger.ts' import { useEnterKeyTrigger } from '@/utils/hooks/useEnterKeyTrigger.ts'
interface UserMark{ interface UserMark {
userId: number userId: number
userMark: string userMark: string
userName: string userName: string
...@@ -1192,23 +1214,30 @@ async function handlePrintProductTag() { ...@@ -1192,23 +1214,30 @@ async function handlePrintProductTag() {
window.open(filePath + res.message, '_blank') window.open(filePath + res.message, '_blank')
} }
const batchAddCommodity = async (sku: string,type:string): Promise<InterskuList[]> => { const batchAddCommodity = async (
sku: string,
type: string,
): Promise<InterskuList[]> => {
if (!editForm.value.warehouseId) { if (!editForm.value.warehouseId) {
ElMessage.error('请选择仓库') ElMessage.error('请选择仓库')
return [] return []
} }
try { try {
let userValue: string | number = '' let userValue: string | number = ''
if(type==='1'){ if (type === '1') {
userValue = userMark.value userValue = userMark.value
}else if(type==='2'){ } else if (type === '2') {
userValue = batchUserMark.value userValue = batchUserMark.value
}else if(type==='3'){ } else if (type === '3') {
userValue = importUserMark.value userValue = importUserMark.value
} }
const item = userMarkList.value.find(e=>e.userId===userValue) const item = userMarkList.value.find((e) => e.userId === userValue)
const user = userValue===0 ? null : item?.userMark const user = userValue === 0 ? null : item?.userMark
const res = await getBySkuAndUserMarkApi(editForm.value.warehouseId, sku,user) const res = await getBySkuAndUserMarkApi(
editForm.value.warehouseId,
sku,
user,
)
const arr: InterskuList[] = res.data || [] const arr: InterskuList[] = res.data || []
const ids: Record<string, boolean> = {} const ids: Record<string, boolean> = {}
// 过滤掉商品列表已经加了的 // 过滤掉商品列表已经加了的
...@@ -1297,7 +1326,7 @@ const handleLocalImport = async ({ ...@@ -1297,7 +1326,7 @@ const handleLocalImport = async ({
// 2. 提取导入的 SKU 列表 // 2. 提取导入的 SKU 列表
const importedSkus = importedData.map((item) => item.warehouseSku).join(',') const importedSkus = importedData.map((item) => item.warehouseSku).join(',')
// 3. 调用 batchAddCommodity 获取商品的完整信息并过滤掉已有的 SKU // 3. 调用 batchAddCommodity 获取商品的完整信息并过滤掉已有的 SKU
const filteredSkusList = await batchAddCommodity(importedSkus,'3') // 使用 await 等待结果 const filteredSkusList = await batchAddCommodity(importedSkus, '3') // 使用 await 等待结果
if (filteredSkusList.length === 0) { if (filteredSkusList.length === 0) {
ElMessage.warning('导入的商品SKU已存在或无效') ElMessage.warning('导入的商品SKU已存在或无效')
importedFileUrl.value = path importedFileUrl.value = path
...@@ -1307,15 +1336,17 @@ const handleLocalImport = async ({ ...@@ -1307,15 +1336,17 @@ const handleLocalImport = async ({
// 4. 将备注信息合并到获取到的商品列表中 // 4. 将备注信息合并到获取到的商品列表中
const mergedProductList = filteredSkusList.map((skuItem) => { const mergedProductList = filteredSkusList.map((skuItem) => {
// 在导入数据中找到匹配的备注信息 // 在导入数据中找到匹配的备注信息
const importedItem = importedData.find( const importedItem = importedData.find((item) =>
(item) => skuItem.warehouseSku?.includes(item.warehouseSku), skuItem.warehouseSku?.includes(item.warehouseSku),
) )
const target = locationList.value.find((item: InterProductList) => { const target = locationList.value.find((item: InterProductList) => {
return item.locationCode == importedItem?.locationCode return item.locationCode == importedItem?.locationCode
}) })
const item = userMarkList.value.find(e=>e.userId===importUserMark.value) const item = userMarkList.value.find(
(e) => e.userId === importUserMark.value,
)
return { return {
customerId:importUserMark.value !== 0 ?importUserMark.value : null, customerId: importUserMark.value !== 0 ? importUserMark.value : null,
customerName: importUserMark.value !== 0 ? item?.userName || '' : null, customerName: importUserMark.value !== 0 ? item?.userName || '' : null,
userMark: importUserMark.value !== 0 ? item?.userMark : null, userMark: importUserMark.value !== 0 ? item?.userMark : null,
skuImage: skuItem.skuImage, skuImage: skuItem.skuImage,
...@@ -1409,9 +1440,13 @@ const skuData = ref<InterskuList[]>([]) ...@@ -1409,9 +1440,13 @@ const skuData = ref<InterskuList[]>([])
const selectbySku = async () => { const selectbySku = async () => {
if (!editForm.value.warehouseId) return ElMessage.error('请选择仓库') if (!editForm.value.warehouseId) return ElMessage.error('请选择仓库')
try { try {
const item = userMarkList.value.find(e=>e.userId===userMark.value) const item = userMarkList.value.find((e) => e.userId === userMark.value)
const user = userMark.value===0 ? null : item?.userMark const user = userMark.value === 0 ? null : item?.userMark
const res = await getBySkuAndUserMarkApi(editForm.value.warehouseId, selectSku.value,user) const res = await getBySkuAndUserMarkApi(
editForm.value.warehouseId,
selectSku.value,
user,
)
skuData.value = res.data || [] skuData.value = res.data || []
} catch (e) { } catch (e) {
console.error(e) console.error(e)
...@@ -1440,16 +1475,16 @@ const skudblclick = (val: InterskuList) => { ...@@ -1440,16 +1475,16 @@ const skudblclick = (val: InterskuList) => {
return return
} }
} }
const item = userMarkList.value.find(e=>e.userId===userMark.value) const item = userMarkList.value.find((e) => e.userId === userMark.value)
otherPurchaseData.value = [ otherPurchaseData.value = [
...JSON.parse(JSON.stringify(otherPurchaseData.value)), ...JSON.parse(JSON.stringify(otherPurchaseData.value)),
{ {
skuImage, skuImage,
warehouseSku, warehouseSku,
customerId:userMark.value !== 0 ?userMark.value : null, customerId: userMark.value !== 0 ? userMark.value : null,
customerName: userMark.value !== 0 ? item?.userName || '' : null, customerName: userMark.value !== 0 ? item?.userName || '' : null,
userMark: userMark.value !== 0 ? item?.userMark : null, userMark: userMark.value !== 0 ? item?.userMark : null,
skuName:productName, skuName: productName,
productNo, productNo,
locationCode: locationCode ?? '', // 确保空值处理 locationCode: locationCode ?? '', // 确保空值处理
locationId: locationId ?? null, // 确保空值处理 locationId: locationId ?? null, // 确保空值处理
...@@ -1498,10 +1533,10 @@ const formId = ref<number | undefined>(undefined) ...@@ -1498,10 +1533,10 @@ const formId = ref<number | undefined>(undefined)
const otherPurchaseData = ref<InterProductList[]>([]) const otherPurchaseData = ref<InterProductList[]>([])
const getUserMark = async () => { const getUserMark = async () => {
const {data} = await getLocalFactoryList() const { data } = await getLocalFactoryList()
userMarkList.value = [ userMarkList.value = [
...[{userMark:'九猫商品', userId: 0,userName:''}], ...[{ userMark: '九猫商品', userId: 0, userName: '' }],
...data ...data,
] ]
} }
...@@ -1664,6 +1699,14 @@ watch( ...@@ -1664,6 +1699,14 @@ watch(
}, },
) )
const addOtherCurrency = async () => { const addOtherCurrency = async () => {
console.log(11111)
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
try { try {
await editFormRef.value?.validate() await editFormRef.value?.validate()
} catch { } catch {
...@@ -1692,20 +1735,27 @@ const addOtherCurrency = async () => { ...@@ -1692,20 +1735,27 @@ const addOtherCurrency = async () => {
} }
} }
if (!formId.value) { if (!formId.value) {
addSection() await addSection()
} else { } else {
upSection() await upSection()
}
} catch (error) {
console.log(error)
} finally {
loading.close()
} }
} }
const filterSkuData = computed(() => { const filterSkuData = computed(() => {
const skuList = otherPurchaseData.value.map((el) => el.warehouseSku) const skuList = otherPurchaseData.value.map((el) => el.warehouseSku)
// console.log(skuList, skuData.value) // console.log(skuList, skuData.value)
const item = userMarkList.value.find(u=>u.userId===userMark.value) const item = userMarkList.value.find((u) => u.userId === userMark.value)
return skuData.value.filter((el) => !skuList.includes(el.warehouseSku)).map(e=>{ return skuData.value
.filter((el) => !skuList.includes(el.warehouseSku))
.map((e) => {
return { return {
...e, ...e,
userMark:userMark.value===0?'':item?.userMark userMark: userMark.value === 0 ? '' : item?.userMark,
} }
}) })
}) })
...@@ -1782,11 +1832,11 @@ const submitPurchase = async () => { ...@@ -1782,11 +1832,11 @@ const submitPurchase = async () => {
ElMessage.warning('请输入库存 SKU') ElMessage.warning('请输入库存 SKU')
return return
} }
const item = userMarkList.value.find(e=>e.userId===batchUserMark.value) const item = userMarkList.value.find((e) => e.userId === batchUserMark.value)
const filteredSkusList = await batchAddCommodity(purchaseTextarea.value,'2') const filteredSkusList = await batchAddCommodity(purchaseTextarea.value, '2')
const mergedProductList = filteredSkusList.map((skuItem) => { const mergedProductList = filteredSkusList.map((skuItem) => {
return { return {
customerId:batchUserMark.value !== 0 ?batchUserMark.value : null, customerId: batchUserMark.value !== 0 ? batchUserMark.value : null,
customerName: batchUserMark.value !== 0 ? item?.userName || '' : null, customerName: batchUserMark.value !== 0 ? item?.userName || '' : null,
userMark: batchUserMark.value !== 0 ? item?.userMark : null, userMark: batchUserMark.value !== 0 ? item?.userMark : null,
skuImage: skuItem.skuImage, skuImage: skuItem.skuImage,
...@@ -1851,7 +1901,7 @@ const searchDetail = async () => { ...@@ -1851,7 +1901,7 @@ const searchDetail = async () => {
detailLoading.value = true detailLoading.value = true
try { try {
const res = await getWarehouseInRecordDetailApi(currentRow.value?.id) const res = await getWarehouseInRecordDetailApi(currentRow.value?.id)
res.data.productList.forEach(item => { res.data.productList.forEach((item) => {
item.currencyName = res.data.currencyName || '' item.currencyName = res.data.currencyName || ''
item.currencyCode = res.data.currencyCode || '' item.currencyCode = res.data.currencyCode || ''
}) })
......
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