Commit 9f9aa652 by wuqian

初版出库单

parent 79c91be7
......@@ -6,9 +6,9 @@ import {
InterWarehouseTree,
InterWarehouseDetail,
InterskuList,
InterWarehouseList,
ILocation,
AnyObject,
InterProductList,
} from '@/types/api/warehouse'
export interface LogListData {
createTime: string
......@@ -17,26 +17,26 @@ export interface LogListData {
}
export interface Address {
id: number; // 主键,自动递增
shipperName: string; // 发货人姓名
addressLine1: string; // 地址 1
addressLine2?: string | null; // 地址 2
addressLine3?: string | null; // 地址 3
city: string; // 城市
cityCode?: string | null; // 城市编码
district?: string | null; // 区
districtCode?: string | null; // 区编码
cspAccount?: string | null; // CSP账号
stateProvince?: string | null; // 州/省
stateProvinceAbbr?: string | null; // 州/省简称
postalCode?: string | null; // 邮编
countryName: string; // 国家名称
countryCode?: string | null; // 国家代码
phoneNumber?: string | null; // 电话
rfcTaxId?: string | null; // RFC税号
swDefault?: number | null; // 是否默认 1是,0不是
createTime: string; // 创建时间
updateTime: string; // 更新时间
id: number // 主键,自动递增
shipperName: string // 发货人姓名
addressLine1: string // 地址 1
addressLine2?: string | null // 地址 2
addressLine3?: string | null // 地址 3
city: string // 城市
cityCode?: string | null // 城市编码
district?: string | null // 区
districtCode?: string | null // 区编码
cspAccount?: string | null // CSP账号
stateProvince?: string | null // 州/省
stateProvinceAbbr?: string | null // 州/省简称
postalCode?: string | null // 邮编
countryName: string // 国家名称
countryCode?: string | null // 国家代码
phoneNumber?: string | null // 电话
rfcTaxId?: string | null // RFC税号
swDefault?: number | null // 是否默认 1是,0不是
createTime: string // 创建时间
updateTime: string // 更新时间
}
export interface PrintData {
......@@ -257,7 +257,7 @@ export function updateWarehouseApi(data: positionInfo | UpdateDefaulted) {
export function logisticsAddressGetAllList() {
return axios.get<never, BaseRespData<Address[]>>(
'/logisticsAddress/getAllList'
'/logisticsAddress/getAllList',
)
}
......@@ -371,7 +371,10 @@ export function getWarehouseInRecordDetailApi(id: number | undefined) {
},
)
}
export function getBySkuApi(warehouseId: number | null | undefined, sku: string | null) {
export function getBySkuApi(
warehouseId: number | string | undefined,
sku: string | null,
) {
return axios.get<never, BaseRespData<InterskuList[]>>(
'customProductItem/getBySku',
{
......@@ -383,7 +386,7 @@ export function getBySkuApi(warehouseId: number | null | undefined, sku: string
)
}
export function getByWareHouseIdAndCodeApi(
wareHouseId: number | null | undefined,
wareHouseId: number | string | undefined,
code: string | null,
) {
return axios.get<never, BaseRespData<ILocation[]>>(
......@@ -402,11 +405,6 @@ export function getInRecordStatusTree() {
)
}
export function getWarehouseListApi() {
return axios.get<never, BaseRespData<InterWarehouseList[]>>(
'factoryWarehouseInfo/getAll',
)
}
interface WarehouseParams {
id?: number
dataVersion?: number
......@@ -433,6 +431,78 @@ export function getOutRecordStatusTree() {
'factory/warehouseOutRecord/status_tree',
)
}
export function getBySkuAndWarehouseIdApi(
warehouseId: number | string | undefined,
sku: string | null,
) {
return axios.get<never, BaseRespData<InterskuList[]>>(
'factoryWarehouseInventory/getBySkuAndWarehouseId',
{
params: {
warehouseId,
sku,
},
},
)
}
export function rejectOutRecordApi({
list,
rejectReason,
}: {
list: WarehouseParams[]
rejectReason: string
}) {
return axios.post<never, BaseRespData<never>>(
'factory/warehouseOutRecord/reject',
{
list,
rejectReason,
},
)
}
export function getItemListByIdApi(id: number | undefined) {
return axios.get<never, BaseRespData<InterProductList[]>>(
'factory/warehouseOutRecord/getItemListById',
{
params: {
id,
},
},
)
}
export function getWarehouseOutRecordDetailApi(id: number | undefined) {
return axios.get<never, BaseRespData<InterWarehouseDetail>>(
'factory/warehouseOutRecord/get',
{
params: {
id,
},
},
)
}
export function addOutRecordApi(form: InterWarehouseDetail) {
return axios.post<never, BaseRespData<never>>(
'factory/warehouseOutRecord/add',
{
...form,
},
)
}
export function updateOutRecordApi(
form: InterWarehouseDetail | AnyObject | null,
) {
return axios.post<never, BaseRespData<never>>(
'factory/warehouseOutRecord/update',
{
...form,
},
)
}
export function getOutRecordLogApi(id?: number) {
return axios.get<never, BaseRespData<LogListData[]>>(
`factory/warehouseOutRecord/getLogById?id=${id}`,
)
}
export function warehouseOutRecordListPage(
data: warehouseSearchForm,
currentPage: number,
......
......@@ -27,7 +27,7 @@ import WarehouseManage from '@/views/warehouse/manage.vue'
import WarehouseWarning from '@/views/warehouse/warning.vue'
import WarehousePosition from '@/views/warehouse/position.vue'
import receiptDoc from '@/views/warehouse/receiptDoc.vue'
// import issueDoc from '@/views/warehouse/issueDoc.vue'
import issueDoc from '@/views/warehouse/issueDoc.vue'
const router = createRouter({
history: createWebHistory(),
routes: [
......@@ -134,13 +134,13 @@ const router = createRouter({
},
component: receiptDoc,
},
// {
// path: '/warehouse/issue-doc',
// meta: {
// title: '出库单',
// },
// component: issueDoc,
// },
{
path: '/warehouse/issue-doc',
meta: {
title: '出库单',
},
component: issueDoc,
},
{
path: '/warehouse/warning',
meta: {
......
......@@ -31,11 +31,11 @@ const menu: MenuItem[] = [
id: 123,
label: '入库单',
},
// {
// index: '/warehouse/issue-doc',
// id: 124,
// label: '出库单',
// },
{
index: '/warehouse/issue-doc',
id: 124,
label: '出库单',
},
{
index: '/warehouse/manage',
......
......@@ -8,7 +8,7 @@ export interface warehouseSearchForm {
createTimeStart?: string
orderNumber?: string
sku?: string
warehouseId?: number | null
warehouseId?: number | string
id?: number
}
export interface InterProductList {
......@@ -16,7 +16,8 @@ export interface InterProductList {
id?: number
inId?: number
productNo?: string | null //custom的货号
buyStored?: number | null
buyStored?: number | null //入库数量
outCount?: number | null //出库数量
remark?: string | null
skuImage?: string
skuName?: string
......@@ -32,9 +33,10 @@ export interface InterWarehouseBase {
id?: number
factoryId?: number
factoryCode?: string
warehouseId?: number | null
warehouseId?: number | string
warehouseName?: string | null
inNo?: string
outNo?: string
shipmentNumber?: string
skuAmount?: number
total?: number
......@@ -66,6 +68,8 @@ export interface InterProductList {
inId?: number
productNo?: string | null //货号
buyStored?: number | null //入库数量
outCount?: number | null //出库数量
usableInventory?: number | null //可用库存数量
// rejectsAmount?: number
// rejectsReason?: string
remark?: string | null
......@@ -84,20 +88,14 @@ export interface InterskuList {
sku?: string
skuName?: string
image?: string
factoryPrice?: number
factoryPrice?: number | null
productNo?: string | null //货号
productNumber?: string | null //出库单货号
locationId?: number | null
locationCode?: string | null
}
export interface InterWarehouseList {
id: number
name: string
code?: string
sort?: number
defaulted?: number
factoryId?: number
factoryCode?: string
remarks?: string | null
price?: number | null //出库单的
usableInventory?: number | null
warehouseSku?: string
}
export interface ILocation {
id?: number
......
......@@ -29,6 +29,7 @@ function isChange(arr: AnyObject[], arr1: AnyObject[]): boolean {
* @param {string} id 数组唯一值
* @param {Record<string, string>} other 其他属性
* @param {boolean} bool 是否为布尔值
* @param {boolean} isBackKeyName 是否将结果返回到xxChange里,针对只有一个list的情况
*/
export function checkUpdateParams(
newParams: AnyObject,
......@@ -36,6 +37,7 @@ export function checkUpdateParams(
id: string = 'id',
other: Record<string, string> = {},
bool: boolean = false,
isBackKeyName: boolean = true,
): AnyObject | null {
oldParams = JSON.parse(JSON.stringify(oldParams))
if (!oldParams) return newParams
......@@ -105,24 +107,32 @@ export function checkUpdateParams(
if (arr1.length > 0) {
removeList = arr1.map((item) => 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]
if (isBackKeyName) {
// 将列表直接添加到 params 顶层
if (addList.length > 0) params['addList'] = addList || undefined
if (updateList.length > 0)
params['updateList'] = updateList || undefined
if (removeList.length > 0)
params['removeList'] = removeList || undefined
if (list.length > 0) params['list'] = list || undefined
} else {
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 {
......
......@@ -46,7 +46,7 @@
></ElOption>
</ElSelect>
</ElFormItem>
<ElFormItem label="库时间">
<ElFormItem label="库时间">
<el-date-picker
v-model="tradingTime"
:shortcuts="pickerOptions.shortcuts"
......@@ -67,7 +67,7 @@
<ElInput
v-model="searchForm.orderNumber"
clearable
placeholder="请输入库单号"
placeholder="请输入库单号"
style="width: 160px"
/>
</ElFormItem>
......@@ -188,9 +188,9 @@
align="center"
></ElTableColumn>
<ElTableColumn
label="库单号"
label="库单号"
show-overflow-tooltip
prop="inNo"
prop="outNo"
width="130"
header-align="center"
align="center"
......@@ -295,7 +295,7 @@
</template>
<template #bottom>
<el-tabs v-model="tabsValue" @tab-click="tabsClick">
<el-tab-pane name="0" label="库商品">
<el-tab-pane name="0" label="库商品">
<div class="table-wrap">
<ElTable size="small" :data="detailList" height="100%" border>
<ElTableColumn
......@@ -337,8 +337,8 @@
<ElTableColumn
show-overflow-tooltip
align="center"
label="库数量"
prop="buyStored"
label="库数量"
prop="outCount"
/>
<ElTableColumn
show-overflow-tooltip
......@@ -352,18 +352,6 @@
label="总成本(¥)"
prop="totalPrice"
/>
<!-- <ElTableColumn
show-overflow-tooltip
align="center"
label="不良品数量"
prop="rejectsAmount"
/>
<ElTableColumn
show-overflow-tooltip
align="center"
label="不良品原因"
prop="rejectsAeason"
/> -->
<ElTableColumn
show-overflow-tooltip
align="center"
......@@ -385,18 +373,6 @@
/>
</ElTable>
</div>
<!-- <ElPagination
v-model:current-page="detailPager.page"
v-model:page-size="detailPager.rows"
:page-sizes="[100, 200, 300, 400, 500]"
background
layout="total, sizes, prev, pager, next, jumper"
:total="detailPager.total"
style="margin: 10px auto 0; text-align: right"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
></ElPagination> -->
</el-tab-pane>
<el-tab-pane name="1" label="操作日志">
<ul
......@@ -434,12 +410,6 @@
:close-on-click-modal="false"
>
<div class="import-dialog">
<!-- <div class="import-header">
<el-button type="primary" link @click="downloadTemplate">
<el-icon><Download /></el-icon>
下载模板
</el-button>
</div> -->
<div class="import-content">
<UploadExcel
v-model="importedFileUrl"
......@@ -448,12 +418,6 @@
/>
</div>
</div>
<!-- <template #footer>
<span class="dialog-footer">
<el-button @click="importDialogVisible = false">取消</el-button>
<el-button type="primary" @click="packedData">确认</el-button>
</span>
</template> -->
</ElDialog>
<ElDialog
v-model="newDialogVisible"
......@@ -469,8 +433,8 @@
inline
label-width="90px"
>
<ElFormItem label="库单号" prop="account">
<ElInput v-model="editForm.inNo" clearable disabled />
<ElFormItem label="库单号" prop="account">
<ElInput v-model="editForm.outNo" clearable disabled />
</ElFormItem>
<ElFormItem label="工厂:" prop="factoryCode">
<span>{{ editForm.factoryCode }}</span>
......@@ -479,6 +443,7 @@
<ElSelect
v-model="editForm.warehouseId"
clearable
:disabled="formId"
placeholder="请选择仓库"
style="width: 160px"
@change="handleWarehouseChange(editForm.warehouseId)"
......@@ -536,12 +501,17 @@
label="SKU名称"
prop="skuName"
/>
<ElTableColumn align="center" label="入库数量" prop="buyStored">
<ElTableColumn
show-overflow-tooltip
align="center"
label="可用库存数量"
prop="usableInventory"
/>
<ElTableColumn align="center" label="出库数量" prop="outCount">
<template #default="{ row }">
<el-input
v-model.number="row.buyStored"
placeholder="库数量"
v-model.number="row.outCount"
placeholder="库数量"
style="width: 120px"
clearable
size="small"
......@@ -561,13 +531,9 @@
label="总成本(¥)"
prop="totalPrice"
/>
<ElTableColumn align="center" label="库位" prop="loacationCode">
<ElTableColumn align="center" label="库位" prop="locationCode">
<template #default="{ row }">
<!-- +后有就正常展示,没有则通过搜索接口自己添加 -->
<!-- remote
:remote-method="(query) => handleLocationSearch(query, row)"
:loading="locationLoading"-->
<span v-if="row.loacationCode">{{ row.loacationCode }}</span>
<span v-if="row.locationCode">{{ row.locationCode }}</span>
<ElSelect
v-else
v-model="row.locationId"
......@@ -592,7 +558,11 @@
width="240"
label="备注"
prop="remark"
/>
>
<template #default="{ row }">
<ElInput v-model="row.remark" clearable size="small" />
</template>
</ElTableColumn>
</ElTable>
</div>
<template #footer>
......@@ -639,7 +609,7 @@
align="center"
width="200"
label="SKU名称"
prop="sku"
prop="warehouseSku"
/>
<ElTableColumn
......@@ -647,13 +617,13 @@
align="center"
label="成本价(¥)"
width="100"
prop="factoryPrice"
prop="price"
/>
<ElTableColumn
show-overflow-tooltip
align="center"
label="库位"
prop="loacationCode"
prop="locationCode"
/>
<ElTableColumn
width="100"
......@@ -680,14 +650,14 @@
</el-button>
</template>
</el-popover>
<el-button
<!-- <el-button
style="margin-left: 6px"
type="success"
size="small"
@click="addPurchase"
>
批量新增
</el-button>
</el-button> -->
<el-button
type="danger"
style="margin-left: 10px"
......@@ -800,19 +770,21 @@ import usePageList from '@/utils/hooks/usePageList'
import { checkUpdateParams, AnyObject } from '@/utils/hooks/commonUtil'
import { useValue } from '@/utils/hooks/useValue'
import {
getInRecordStatusTree,
warehouseInRecordListPageApi,
getWarehouseInRecordDetailApi,
getBySkuApi,
getWarehouseListApi,
getOutRecordStatusTree,
warehouseOutRecordListPage,
getWarehouseOutRecordDetailApi,
getItemListByIdApi,
getBySkuAndWarehouseIdApi,
warehouseInfoGetAll,
getByWareHouseIdAndCodeApi,
addInRecordApi,
updateInRecordApi,
deleteWarehouseInRecordApi,
addOutRecordApi,
updateOutRecordApi,
deleteWarehouseOutRecordApi,
auditOrderApi,
getInRecordLogApi,
rejectInRecordApi,
getOutRecordLogApi,
rejectOutRecordApi,
LogListData,
warehouseInfo,
} from '@/api/warehouse'
// factoryWarehouseInventoryPrint,
// import { filePath } from '@/api/axios.ts'
......@@ -825,14 +797,13 @@ import {
InterWarehouseTree,
InterProductList,
InterskuList,
InterWarehouseList,
ILocation,
InterWarehouseDetail,
} from '@/types/api/warehouse'
import ImageView from '@/components/ImageView.vue'
import UploadExcel from '@/components/UploadExcel.vue'
// import { debounce } from 'lodash-es'
const warehouseList = ref<InterWarehouseList[]>([])
const warehouseList = ref<warehouseInfo[]>([])
const pickerOptions = {
shortcuts: [
{
......@@ -979,7 +950,7 @@ const {
onPageSizeChange: handleSizeChange,
} = usePageList({
query: (page, pageSize) =>
warehouseInRecordListPageApi(
warehouseOutRecordListPage(
{
...searchForm.value,
billStatus: nodeCode.value == 'all' ? 'all' : nodeCode.value,
......@@ -997,15 +968,15 @@ const setCostPrice = (item: InterProductList) => {
return
}
if (item) {
const buyStored = item.buyStored ?? 0
const outCount = item.outCount ?? 0
const costPrice = item.costPrice ?? 0
const amount = new BigNumber(buyStored).multipliedBy(costPrice).toFixed(2)
const amount = new BigNumber(outCount).multipliedBy(costPrice).toFixed(2)
item.totalPrice = Number(amount)
}
}
const getTreeNum = async () => {
try {
const res = await getInRecordStatusTree()
const res = await getOutRecordStatusTree()
res.data = [{ code: 'all', name: '全部', children: res.data }]
treeData.value = res.data
await nextTick(() => {
......@@ -1051,7 +1022,8 @@ const excelFieldMap: Record<string, keyof InterProductList> = {
SKU图片: 'skuImage',
商品SKU: 'warehouseSku',
SKU名称: 'skuName',
入库数量: 'buyStored',
出库数量: 'outCount',
可用库存数量: 'usableInventory',
'成本价(¥)': 'costPrice',
'总成本(¥)': 'totalPrice',
库位: 'locationCode',
......@@ -1071,7 +1043,7 @@ const handleLocalImport = ({
const field = excelFieldMap[excelKey] as keyof InterProductList
const value = item[excelKey]
// // 类型转换和默认值
// if (['buyStored', 'costPrice', 'totalPrice'].includes(field)) {
// if (['outCount', 'costPrice', 'totalPrice'].includes(field)) {
// value = value == null || value === '' ? 0 : Number(value)
// } else {
// value = value == null ? '' : value
......@@ -1092,110 +1064,10 @@ const exportForm = ref({
// const handleExport = () => {
// exportVisible.value = true
// }
const submitExportForm = () => {
// if (exportForm.value.resource === '') {
// return ElMessage.error('请选择导出类型')
// }
// let purchaseIds = [],
// otherIds = [],
// total = 0,
// params = {}
// if (exportForm.value.resource === 0) {
// purchaseIds = userData.value
// .filter((el) => el.dataType === 0)
// .map((el) => el.id)
// .join(',')
// otherIds = userData.value
// .filter((el) => el.dataType === 1)
// .map((el) => el.id)
// .join(',')
// } else if (exportForm.value.resource === 1) {
// purchaseIds = selections.value
// .filter((el) => el.dataType === 0)
// .map((el) => el.id)
// .join(',')
// otherIds = selections.value
// .filter((el) => el.dataType === 1)
// .map((el) => el.id)
// .join(',')
// } else {
// purchaseIds = ''
// otherIds = ''
// // total = this.paginationOptions.total
// }
// params = {
// purchaseIds,
// otherIds,
// total,
// }
// if (exportForm.value.resource !== 2) {
// delete params.total
// } else {
// // params.billStatus = this.billStatus
// // params.type = this.treeType || ''
// // params.otherStatus = this.otherStatus
// if (
// this.treeLabel.indexOf(this.$t('待入库')) !== -1 ||
// this.treeLabel.indexOf(this.$t('已入库')) !== -1
// ) {
// params.purchaseAll = true
// params.otherAll = true
// }
// if (
// this.treeLabel.indexOf(this.$t('采购')) !== -1 ||
// this.treeLabel.indexOf(this.$t('生产')) !== -1
// ) {
// params.purchaseAll = true
// }
// if (this.treeLabel.indexOf(this.$t('其他')) !== -1) {
// params.otherAll = true
// }
// if (this.treeLabel.indexOf(this.$t('归档')) !== -1) {
// params.purchaseAll = true
// }
// if (this.treeLabel.indexOf(this.$t('作废')) !== -1) {
// params.purchaseAll = true
// params.otherAll = true
// }
// }
// const loading = this.$loading({
// background: 'rgba(0, 0, 0, 0.3)',
// })
// Axios.post(
// window.apiHostSetting.VUE_APP_API_URL +
// 'api/purchaseStoreBill/exportPurchaseExcel',
// {
// includeSku: exportForm.value.delivery,
// ...params,
// ...this.searchForm,
// },
// {
// headers: {
// 'jwt-token': localStorage.getItem('token'),
// },
// },
// )
// .then((res) => {
// console.log(filePath)
// window.open(filePath + res.data.message)
// exportVisible.value = false
// })
// .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 submitExportForm = () => {}
const getWarehouseList = async () => {
try {
const res = await getWarehouseListApi()
const res = await warehouseInfoGetAll()
warehouseList.value = res.data
await nextTick(() => {
treeRef.value!.setCurrentKey(nodeCode.value, true)
......@@ -1215,7 +1087,10 @@ const skuData = ref<InterskuList[]>([])
const selectbySku = async () => {
if (!editForm.value.warehouseId) return ElMessage.error('请选择仓库')
try {
const res = await getBySkuApi(editForm.value.warehouseId, selectSku.value)
const res = await getBySkuAndWarehouseIdApi(
editForm.value.warehouseId,
selectSku.value,
)
skuData.value = res.data || []
} catch (e) {
console.error(e)
......@@ -1225,25 +1100,27 @@ const skudblclick = (val: InterskuList) => {
// 使用可选链和空值合并运算符处理可能的null值
const {
locationCode = '',
factoryPrice = 0,
productNo = '',
sku = '',
price = null,
productNumber = '',
warehouseSku = '',
skuName = '',
image = '',
locationId = null,
usableInventory = null,
} = val || {}
otherPurchaseData.value = [
...otherPurchaseData.value,
{
skuImage: image,
warehouseSku: sku,
warehouseSku,
skuName,
productNo,
productNo: productNumber,
locationCode: locationCode ?? '', // 确保空值处理
locationId: locationId ?? null, // 确保空值处理
costPrice: factoryPrice,
buyStored: null,
costPrice: price,
outCount: null, //出库数量
totalPrice: null,
usableInventory, //可用库存数量
},
]
// 使用filter代替forEach+splice,时间复杂度从O(n^2)降到O(n)
......@@ -1251,7 +1128,7 @@ const skudblclick = (val: InterskuList) => {
otherPurchaseData.value.map((item: InterProductList) => item.warehouseSku),
)
skuData.value = skuData.value.filter(
(item: InterskuList) => !skuSet.has(item.sku),
(item: InterskuList) => !skuSet.has(item.warehouseSku),
)
}
const tabsClick = async () => {
......@@ -1268,8 +1145,8 @@ const tabsClick = async () => {
}
}
const [editForm, resetEditForm] = useValue<InterWarehouseDetail>({
inNo: '',
warehouseId: null,
outNo: '',
warehouseId: '',
warehouseName: '',
remark: '',
factoryCode: '',
......@@ -1286,7 +1163,7 @@ const addDialog = async (i: number, v: InterWarehousePage | null) => {
if (v) formId.value = v.id
if (v) getProduct(v.id)
if (!formId.value) return ElMessage('请勾选至少一条记录')
editForm.value = JSON.parse(JSON.stringify(v))
// editForm.value = JSON.parse(JSON.stringify(v))
} else {
await nextTick()
editForm.value = JSON.parse(JSON.stringify(editForm2.value))
......@@ -1297,6 +1174,13 @@ const addDialog = async (i: number, v: InterWarehousePage | null) => {
const userData = JSON.parse(userJson)
editForm.value.factoryCode = userData.factoryCode || ''
editForm.value.factoryId = userData.factoryId || 0
const defaultWarehouse = warehouseList.value.find(
(item: warehouseInfo) => item.defaulted === 1,
)
if (defaultWarehouse) {
editForm.value.warehouseId = defaultWarehouse.id
editForm.value.warehouseName = defaultWarehouse.name
}
} catch {
// ignore
}
......@@ -1309,7 +1193,7 @@ const addDialog = async (i: number, v: InterWarehousePage | null) => {
}
const getProduct = async (id: number | undefined) => {
try {
const res = await getWarehouseInRecordDetailApi(id)
const res = await getWarehouseOutRecordDetailApi(id)
editForm.value = JSON.parse(JSON.stringify(res.data))
otherPurchaseData.value = res.data?.productList || []
} catch (e) {
......@@ -1331,19 +1215,19 @@ const auditOrder = (key: string) => {
let text = ''
switch (key) {
case 'invalid':
url = 'factory/warehouseInRecord/invalid'
url = 'factory/warehouseOutRecord/invalid'
text = '作废'
break
case 'archiving':
url = 'factory/warehouseInRecord/archive'
url = 'factory/warehouseOutRecord/archive'
text = '归档'
break
case 'submitAudit':
url = 'factory/warehouseInRecord/submitAudit'
url = 'factory/warehouseOutRecord/submitAudit'
text = '提交审核'
break
case 'audit':
url = 'factory/warehouseInRecord/audit'
url = 'factory/warehouseOutRecord/audit'
text = '审核'
break
}
......@@ -1387,7 +1271,7 @@ const rejectedInRecord = () => {
}),
)
try {
await rejectInRecordApi({ list: data, rejectReason: value })
await rejectOutRecordApi({ list: data, rejectReason: value })
ElMessage.success('操作成功')
search()
await getTreeNum()
......@@ -1413,7 +1297,7 @@ watch(
watch(
() => editForm.value.warehouseId,
(newVal: number | null | undefined) => {
(newVal: number | string | undefined) => {
if (newVal) {
fetchLocationList('')
}
......@@ -1431,8 +1315,13 @@ const addOtherCurrency = async () => {
return
}
for (let i = 0; i < arr.length; i++) {
if (!arr[i].buyStored) {
ElMessage.error('请输入入库数量')
if (!arr[i].outCount) {
ElMessage.error('请输入出库数量')
return
}
const usableInventory = arr[i].usableInventory || 0
if ((arr[i].outCount as number) > usableInventory) {
ElMessage.error('出库数量不能大于可用库存数量')
return
}
if (!arr[i].locationId) {
......@@ -1475,7 +1364,7 @@ const addSection = async () => {
const params = { ...editForm.value }
params.productList = otherPurchaseData.value
try {
await addInRecordApi(params)
await addOutRecordApi(params)
ElMessage.success('保存成功')
newDialogVisible.value = false
search()
......@@ -1512,7 +1401,6 @@ const addSection = async () => {
}
const upSection = async () => {
const params = { ...editForm.value }
// params.productList = otherPurchaseData.value
const result = checkUpdateParams(
{ ...params, productList: otherPurchaseData.value },
editForm.value as unknown as AnyObject,
......@@ -1522,7 +1410,7 @@ const upSection = async () => {
},
)
try {
await updateInRecordApi(result)
await updateOutRecordApi(result)
newDialogVisible.value = false
ElMessage.success('修改成功')
search()
......@@ -1531,9 +1419,9 @@ const upSection = async () => {
console.error(e)
}
}
const addPurchase = async () => {
if (!editForm.value.warehouseId) return ElMessage.error('请选择仓库')
}
// const addPurchase = async () => {
// if (!editForm.value.warehouseId) return ElMessage.error('请选择仓库')
// }
const deleteOtherWarehousing = () => {
const arr = otherWarehouseSelection.value
if (arr.length === 0) return
......@@ -1558,9 +1446,10 @@ const handleBatchDelete = async () => {
type: 'warning',
})
const str = selections.value.map((el: InterWarehousePage) => el.id).join(',')
await deleteWarehouseInRecordApi(str)
await deleteWarehouseOutRecordApi(str)
ElMessage.success('删除成功')
await search()
search()
await getTreeNum()
}
const nodeClick = (data: InterWarehouseTree) => {
nodeCode.value = data.code ?? ''
......@@ -1574,15 +1463,15 @@ const nodeClick = (data: InterWarehouseTree) => {
// })
const searchDetail = async () => {
try {
const res = await getWarehouseInRecordDetailApi(currentRow.value?.id)
detailList.value = res.data?.productList || []
const res = await getItemListByIdApi(currentRow.value?.id)
detailList.value = res.data || []
} catch (e) {
console.error(e)
}
}
const getLogList = async () => {
try {
const res = await getInRecordLogApi(currentRow.value?.id)
const res = await getOutRecordLogApi(currentRow.value?.id)
logList.value = res.data
} catch (e) {
console.error(e)
......@@ -1624,9 +1513,9 @@ const handleLocationChange = (val: number, row: InterProductList) => {
)
row.locationCode = found ? found.locationCode : ''
}
const handleWarehouseChange = (val: number | null | undefined) => {
const handleWarehouseChange = (val: number | string | undefined) => {
const found = warehouseList.value.find(
(item: InterWarehouseList) => item.id === val,
(item: warehouseInfo) => item.id === val,
)
editForm.value.warehouseName = found ? found.name : ''
}
......
......@@ -479,6 +479,7 @@
<ElSelect
v-model="editForm.warehouseId"
clearable
:disabled="formId"
placeholder="请选择仓库"
style="width: 160px"
@change="handleWarehouseChange(editForm.warehouseId)"
......@@ -561,13 +562,13 @@
label="总成本(¥)"
prop="totalPrice"
/>
<ElTableColumn align="center" label="库位" prop="loacationCode">
<ElTableColumn align="center" label="库位" prop="locationCode">
<template #default="{ row }">
<!-- +后有就正常展示,没有则通过搜索接口自己添加 -->
<!-- remote
:remote-method="(query) => handleLocationSearch(query, row)"
:loading="locationLoading"-->
<span v-if="row.loacationCode">{{ row.loacationCode }}</span>
<span v-if="row.locationCode">{{ row.locationCode }}</span>
<ElSelect
v-else
v-model="row.locationId"
......@@ -592,7 +593,11 @@
width="240"
label="备注"
prop="remark"
/>
>
<template #default="{ row }">
<ElInput v-model="row.remark" clearable size="small" />
</template>
</ElTableColumn>
</ElTable>
</div>
<template #footer>
......@@ -653,7 +658,7 @@
show-overflow-tooltip
align="center"
label="库位"
prop="loacationCode"
prop="locationCode"
/>
<ElTableColumn
width="100"
......@@ -680,14 +685,14 @@
</el-button>
</template>
</el-popover>
<el-button
<!-- <el-button
style="margin-left: 6px"
type="success"
size="small"
@click="addPurchase"
>
批量新增
</el-button>
</el-button> -->
<el-button
type="danger"
style="margin-left: 10px"
......@@ -804,7 +809,7 @@ import {
warehouseInRecordListPageApi,
getWarehouseInRecordDetailApi,
getBySkuApi,
getWarehouseListApi,
warehouseInfoGetAll,
getByWareHouseIdAndCodeApi,
addInRecordApi,
updateInRecordApi,
......@@ -813,6 +818,7 @@ import {
getInRecordLogApi,
rejectInRecordApi,
LogListData,
warehouseInfo,
} from '@/api/warehouse'
// factoryWarehouseInventoryPrint,
// import { filePath } from '@/api/axios.ts'
......@@ -825,14 +831,13 @@ import {
InterWarehouseTree,
InterProductList,
InterskuList,
InterWarehouseList,
ILocation,
InterWarehouseDetail,
} from '@/types/api/warehouse'
import ImageView from '@/components/ImageView.vue'
import UploadExcel from '@/components/UploadExcel.vue'
// import { debounce } from 'lodash-es'
const warehouseList = ref<InterWarehouseList[]>([])
const warehouseList = ref<warehouseInfo[]>([])
const pickerOptions = {
shortcuts: [
{
......@@ -1195,7 +1200,7 @@ const submitExportForm = () => {
}
const getWarehouseList = async () => {
try {
const res = await getWarehouseListApi()
const res = await warehouseInfoGetAll()
warehouseList.value = res.data
await nextTick(() => {
treeRef.value!.setCurrentKey(nodeCode.value, true)
......@@ -1225,7 +1230,7 @@ const skudblclick = (val: InterskuList) => {
// 使用可选链和空值合并运算符处理可能的null值
const {
locationCode = '',
factoryPrice = 0,
factoryPrice = null,
productNo = '',
sku = '',
skuName = '',
......@@ -1269,7 +1274,7 @@ const tabsClick = async () => {
}
const [editForm, resetEditForm] = useValue<InterWarehouseDetail>({
inNo: '',
warehouseId: null,
warehouseId: '',
warehouseName: '',
remark: '',
factoryCode: '',
......@@ -1286,7 +1291,7 @@ const addDialog = async (i: number, v: InterWarehousePage | null) => {
if (v) formId.value = v.id
if (v) getProduct(v.id)
if (!formId.value) return ElMessage('请勾选至少一条记录')
editForm.value = JSON.parse(JSON.stringify(v))
// editForm.value = JSON.parse(JSON.stringify(v))
} else {
await nextTick()
editForm.value = JSON.parse(JSON.stringify(editForm2.value))
......@@ -1297,6 +1302,13 @@ const addDialog = async (i: number, v: InterWarehousePage | null) => {
const userData = JSON.parse(userJson)
editForm.value.factoryCode = userData.factoryCode || ''
editForm.value.factoryId = userData.factoryId || 0
const defaultWarehouse = warehouseList.value.find(
(item: warehouseInfo) => item.defaulted === 1,
)
if (defaultWarehouse) {
editForm.value.warehouseId = defaultWarehouse.id
editForm.value.warehouseName = defaultWarehouse.name
}
} catch {
// ignore
}
......@@ -1413,7 +1425,7 @@ watch(
watch(
() => editForm.value.warehouseId,
(newVal: number | null | undefined) => {
(newVal: number | string | undefined) => {
if (newVal) {
fetchLocationList('')
}
......@@ -1531,9 +1543,9 @@ const upSection = async () => {
console.error(e)
}
}
const addPurchase = async () => {
if (!editForm.value.warehouseId) return ElMessage.error('请选择仓库')
}
// const addPurchase = async () => {
// if (!editForm.value.warehouseId) return ElMessage.error('请选择仓库')
// }
const deleteOtherWarehousing = () => {
const arr = otherWarehouseSelection.value
if (arr.length === 0) return
......@@ -1560,7 +1572,8 @@ const handleBatchDelete = async () => {
const str = selections.value.map((el: InterWarehousePage) => el.id).join(',')
await deleteWarehouseInRecordApi(str)
ElMessage.success('删除成功')
await search()
search()
await getTreeNum()
}
const nodeClick = (data: InterWarehouseTree) => {
nodeCode.value = data.code ?? ''
......@@ -1624,9 +1637,9 @@ const handleLocationChange = (val: number, row: InterProductList) => {
)
row.locationCode = found ? found.locationCode : ''
}
const handleWarehouseChange = (val: number | null | undefined) => {
const handleWarehouseChange = (val: number | string | undefined) => {
const found = warehouseList.value.find(
(item: InterWarehouseList) => item.id === val,
(item: warehouseInfo) => item.id === val,
)
editForm.value.warehouseName = found ? found.name : ''
}
......
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