出库对接

This commit is contained in:
zx
2026-04-14 08:46:29 +08:00
parent b16dd22d70
commit 6f1db0f92e
30 changed files with 1366 additions and 458 deletions

View File

@@ -1,8 +1,9 @@
<template>
<view class="page">
<navigation :title="title" :back-url="backUrl"></navigation>
<navigation :title="title" :back-url="backUrl"></navigation>
<view class="contentBox">
<!-- 仓库信息 - 仓库存储区 -->
<warehousing-info ref="warehousingInfoRef" :warehouseInfo="warehouseInfo" :pathParams="pathParams" />
<warehousing-info ref="warehousingInfoRef" :warehouseInfo="warehouseInfo"
:pathParams="{ ...pathParams, type: 'stockIn' }" />
<!-- 物料列表 - 添加物料 -->
<material-list ref="materialRef" :formData="formData" isEdit="1" backStr="stockIn" :pathParams="pathParams" />
<!-- 底部操作栏 -->
@@ -24,18 +25,26 @@ import { getMaterialUnique } from '@/api/uniqueCode';
import MaterialList from '../../components/MaterialList.vue';
import WarehousingInfo from '../../components/WarehousingInfo.vue';
import Navigation from '../../components/Navigation.vue';
import { includes } from 'lodash';
const OPERATE_CONFIG = {
// 创建
list: {
back: 'pages/warehousing/index',
title: '入库单开单'
},
// 编辑/入库
stockIn: {
back: '/pages/warehousing/stockIn/components/detail',
title: ''
}
}
// 数据:路径参数
const pathParams = ref('')
// 标志:是否为编辑
const isEdit = ref('')
// 标志:区分页面 进入页面的状态 null新建 stockIn:入库编辑 stockIn-putAway入库单入库编辑
const flag = ref('')
// ref标题
const title = ref('入库单开单')
const backUrl = ref('pages/warehousing/index')
const title = ref('')
const backUrl = ref('')
// ref物料绑定
const materialRef = ref([])
@@ -49,20 +58,19 @@ const warehouseInfo = ref({ warehousing: {}, storageArea: {}, remark: '' })
// 数据:获取缓存信息
const getMaterialList = () => {
// 获取仓库信息
// 仓库信息
const warehouse = uni.getStorageSync('app_warehousing');
warehouseInfo.value.warehousing = warehouse
// 获取存储区信息
// 存储区信息
const storageArea = uni.getStorageSync('app_storageArea');
warehouseInfo.value.storageArea = storageArea
// 获取物料信息
// 物料信息
const material = uni.getStorageSync('app_material');
formData.value.material = material
// 获取入库单备注
// 入库单备注
const billRemark = uni.getStorageSync('app_billRemark');
warehouseInfo.value.remark = billRemark
}
@@ -128,65 +136,56 @@ const submitForm = () => {
billRemark: info.remark,
itemList: _.map(materialInfo, (i) => ({ ...i.material }))
}
console.log(params, isEdit, !isEdit, info, materialInfo, '入参params');
// 新建
if (!isEdit.value) {
addStockIn(params).then((res) => {
if (res.code == 200) {
uni.showToast({
title: '入库单创建成功',
mask: true,
icon: 'success',
})
uni.navigateTo({
url: `/pages/warehousing/stockIn/my`,
});
}
})
} else if (isEdit.value) {
// 编辑
params.billNo = pathParams.value?.billNo
params.billId = pathParams.value?.billId
const query = objectToQuery(pathParams.value)
stockInUpdate(params).then((res) => {
if (res.code == 200) {
uni.showToast({
title: '入库单编辑成功',
mask: true,
icon: 'success',
})
let url = `/pages/warehousing/stockIn/components/detail${query}`
uni.navigateTo({
url: url,
});
}
})
try {
if (!isEdit.value) {
// 新增
addStockIn(params).then((res) => {
if (res.code == 200) {
uni.showToast({ title: '入库单创建成功', icon: 'success', mask: true })
uni.navigateTo({ url: OPERATE_CONFIG.list.back })
}
})
} else {
// 编辑
params.billNo = pathParams.value?.billNo;
params.billId = pathParams.value?.billId;
const queryStr = objectToQuery(pathParams.value)
stockInUpdate(params).then((res) => {
if (res.code == 200) {
uni.showToast({ title: '入库单编辑成功', icon: 'success', mask: true })
uni.navigateTo({ url: OPERATE_CONFIG.stockIn.back + queryStr })
}
})
}
} catch (err) {
console.error('提交失败:', err)
uni.showToast({ title: '提交失败', icon: 'none' })
}
}
// 数据:路径参数
onLoad((options) => {
console.log(options, 'options', _.includes(options?.type, 'stockIn'));
pathParams.value = options
flag.value = options.type
isEdit.value = _.includes(options?.type, 'stockIn')
})
// 修改标题若有billNo传入 修改标题
onShow(() => {
const query = objectToQuery(pathParams.value)
if (pathParams.value.billNo) {
title.value = pathParams.value.billNo
}
if ( includes(pathParams.value.type,'stockIn') ) {
backUrl.value = `/pages/warehousing/stockIn/components/detail${query}`
console.log('options==>', options);
// 若有billNo传入 修改标题且为编辑 stockIn:入库编辑 stockIn-putAway入库单入库编辑
if (options?.billNo) {
const query = objectToQuery(options)
title.value = options.billNo
backUrl.value = OPERATE_CONFIG.stockIn.back + query;
isEdit.value = true
} else {
isEdit.value = false
title.value = OPERATE_CONFIG.list.title;
backUrl.value = OPERATE_CONFIG.list.back;
}
})
</script>
<style lang="scss" scoped>
.page {
.contentBox {
background: #f5f5f5;
min-height: 100vh;
}