出库对接

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

@@ -5,19 +5,25 @@
<view class="right-btn flex align-center justify-center ">
<uv-image @click="onPrinter" src="../../../../static/printer.png" width="20px" height="20px"
style="margin-top:10rpx" />
<uv-image @click="onEdit" src="../../../../static/edit.png" class="ml-24" width="20px" height="20px"
style="margin-top:10rpx" />
<uv-image @click="toEditOrAway('2')" src="../../../../static/edit.png" class="ml-24" width="20px"
height="20px" style="margin-top:10rpx" />
</view>
</template>
</navigation>
<!-- 详情信息 -->
<detail-info type="stockIn" :detailInfo="detailInfo" />
<view class="contentBox">
<!-- 详情信息 -->
<detail-info :type="pathParams.value?.type" :detailInfo="detailInfo" />
<view v-if="detailInfo?.billType == '0'"
:class="getBillType(detailInfo?.billType, detailInfo?.status) != '物料部分入库' ? 'bottom' : 'bottom1'">
<uv-button type="error" v-if="getBillType(detailInfo?.billType, detailInfo?.status) != '物料部分入库'" text="作废"
@click="toObsolete"></uv-button>
<uv-button type="primary" text="入库单入库" @click="toPutAway"></uv-button>
<!-- 底部按钮 -->
<view v-if="detailInfo?.billType == '0' && !flag"
:class="getBillType(detailInfo?.billType, detailInfo?.status) != '物料部分入库' ? 'bottom' : 'bottom1'">
<uv-button type="error" v-if="getBillType(detailInfo?.billType, detailInfo?.status, flag) != '物料部分入库'"
text="作废" @click="toObsolete"></uv-button>
<uv-button type="primary" text="入库单入库" @click="toEditOrAway('1')"></uv-button>
</view>
<view v-if="detailInfo?.billType == '0' && flag" class="bottom1">
<uv-button type="primary" text="出库单出库" @click="toEditOrAway('1')"></uv-button>
</view>
</view>
</template>
<script setup>
@@ -25,101 +31,139 @@ import _ from 'lodash';
import { ref, computed } from 'vue';
import { onLoad } from "@dcloudio/uni-app";
import { objectToQuery, getBillType } from '../../../until';
import { stockInDetail, inboundBillVoid } from '../../../../api/stockIn';
import { stockOutDetail } from '@/api/stockOut';
import { stockInDetail, inboundBillVoid } from '@/api/stockIn';
import DetailInfo from '../../../components/DetailInfo.vue';
import Navigation from '../../../components/Navigation.vue';
// ref:返回路径
const backUrl = ref('')
// 数据:路径参数
const pathParams = ref('')
// 数据:详情
const detailInfo = ref('')
// 数据:类型 stockIn:入库 stockIn-putAway入库单入库 stockOut出库
const type = computed(() => pathParams.value.type)
// 方法:获取详情 - 将isDelete写入
const getDetailInfo = () => {
stockInDetail({ billNo: pathParams.value.billNo }).then((res) => {
detailInfo.value = res.data
})
// type
const OPERATE_CONFIG = {
// url:入库/出库 地址 back导航栏返回地址 editUrl编辑地址
stockIn: {// 入库单开单
type: 'stockIn',
url: '/pages/warehousing/stockOut/components/outAway',
back: '/pages/warehousing/stockIn/my',
editUrl: '/pages/warehousing/stockIn/create',
},
stockIn_inbound: { // 入库单入库
type: 'stockIn_inbound',
url: '/pages/warehousing/stockIn/components/inbound',
back: '/pages/warehousing/stockIn/putAway',
editUrl: '/pages/warehousing/stockIn/create',
},
stockOut: { // 出库单开单
type: 'stockOut',
url: '/pages/warehousing/stockOut/components/outAway',
back: '/pages/warehousing/stockOut/my',
editUrl: '/pages/warehousing/stockOut/create',
},
stockOut_outAway: { // 出库单入库
type: 'stockOut_outAway',
url: '/pages/warehousing/stockOut/components/outAway',
back: '/pages/warehousing/stockOut/outbound',
editUrl: '/pages/warehousing/stockOut/create',
},
}
const flag = computed(() => _.includes(pathParams.value.type, 'stockIn') ? 0 : 1)
// 打印
const onPrinter = () => {
const onPrinter = () => { }
// 获取详情 - 将isDelete写入
const getDetailInfo = () => {
if (flag.value == 1) {
stockOutDetail({ billNo: pathParams.value.billNo }).then((res) => {
detailInfo.value = res.data
})
} else {
stockInDetail({ billNo: pathParams.value.billNo }).then((res) => {
detailInfo.value = res.data
})
}
}
const toObsolete = () => {
const params = {
inboundBillVoid({
billNo: pathParams.value?.billNo,
billType: '5'
}
inboundBillVoid(params).then((res) => {
// /pages/warehousing/stockIn/my
}).then((res) => {
uni.navigateTo({
url: `/pages/warehousing/stockIn/my`
});
})
}
/**
* 详情信息存入本地缓存
* @param {any} type - 类型标识,控制物料存储逻辑
*/
const setDetailInfoToStorage = (type) => {
const data = detailInfo.value || {}
// 仓库信息
uni.setStorageSync('app_warehousing', [{
deptName: detailInfo.value?.warehouseName,
deptCode: detailInfo.value?.warehouseCode,
deptName: data.warehouseName || '',
deptCode: data.warehouseCode || ''
}])
// 库区信息
uni.setStorageSync('app_storageArea', [{
deptName: detailInfo.value?.areaName,
deptCode: detailInfo.value?.areaCode,
deptName: data.areaName || '',
deptCode: data.areaCode || ''
}])
if (type) {
const material = _.filter(detailInfo.value?.itemList, (i) => i?.uniqueCode && i.status == '0')
const materialSelectList = _.filter(detailInfo.value?.itemList, (i) => !i?.uniqueCode && i.status == '0')
// 单据备注
uni.setStorageSync('app_billRemark', data.billRemark || '')
// 物料列表
const itemList = data.itemList || []
if (!type) {
// 无 type筛选出状态=0 的数据,分两组
const material = _.filter(itemList, i => i?.uniqueCode && i.status === '0')
const materialSelectList = _.filter(itemList, i => !i?.uniqueCode && i.status === '0')
uni.setStorageSync('app_material', material)
uni.setStorageSync('app_material_select_list', materialSelectList)
} else {
uni.setStorageSync('app_material', detailInfo.value?.itemList)
// 有 type直接存储全部 itemList
uni.setStorageSync('app_material', itemList)
}
uni.setStorageSync('app_billRemark', detailInfo.value?.billRemark,)
}
// 按钮:入库单入库
const toPutAway = () => {
setDetailInfoToStorage('1')
const query = objectToQuery(pathParams.value)
uni.navigateTo({
url: `/pages/warehousing/stockIn/components/inbound${query}`
});
}
// 编辑
const onEdit = () => {
setDetailInfoToStorage()
const query = objectToQuery(pathParams.value)
let url = `/pages/warehousing/stockIn/create${query}`
uni.navigateTo({
url: url
});
}
// 接收路径参数billNo
/**
* 路径跳转操作 入库、出库、编辑
* @param {any} type - 类型标识1 出入库操作 2 编辑
*/
const toEditOrAway = (key) => {
const config = flag.value ? OPERATE_CONFIG.stockOut_outAway : OPERATE_CONFIG.stockIn_inbound; // 获取配置flag 区分入库/出库)
console.log(config, 'config===>');
const queryParams = { ...pathParams.value, type: config.type } // 拼接路径参数
const queryStr = objectToQuery(queryParams)
const targetUrl = key === '1' ? config.url : config.editUrl // 区分跳转:操作 / 编辑
setDetailInfoToStorage(key === '1' ? flag.value : undefined)// 存储数据
uni.navigateTo({
url: targetUrl + queryStr
}).catch(err => {
console.error('页面跳转失败:', err)
})
}
// 接收路径参数
onLoad((options) => {
if (!options.billNo) {
uni.showToast({ title: '参数错误,无唯一码ID', icon: 'none' })
return
}
if (options.type == 'stockIn') {
backUrl.value = '/pages/warehousing/stockIn/my'
} else if (options.type == 'stockIn-putAway') {
backUrl.value = '/pages/warehousing/stockIn/putaway'
}
pathParams.value = options
const query = objectToQuery(pathParams.value)
backUrl.value = OPERATE_CONFIG?.[pathParams.value.type]?.back + `${query}`
getDetailInfo()
})
</script>
<style scoped lang="scss">
/* 底部按钮 */
// 底部按钮
.bottom {
position: fixed;

View File

@@ -2,12 +2,11 @@
<template>
<view class="page">
<navigation title="入库" :back-url="backUrl"></navigation>
<!-- 仓库信息 - 仓库存储区 -->
<warehousing-info ref="warehousingInfoRef" :warehouseInfo="warehouseInfo" :pathParams="pathParams" />
<warehousing-info ref="warehousingInfoRef" :warehouseInfo="warehouseInfo"
:pathParams="{ ...pathParams, back: 'stockIn' }" />
<!-- 物料列表 - 添加物料 -->
<material-list ref="materialRef" :formData="formData" isEdit="5" backStr="stockIn" :pathParams="pathParams"
:extendData="{ selectMaterialList }" />
<material-list ref="materialRef" :formData="formData" isEdit="5" :pathParams="pathParams":extendData="{ selectMaterialList }" />
<!-- 底部操作栏 -->
<view class="bottom">
<uv-button type="primary" @click="submitForm">入库</uv-button>
@@ -16,32 +15,25 @@
</template>
<script setup>
import _ from 'lodash';
import { ref } from 'vue';
import { ref, onMounted } from 'vue';
import { onLoad } from "@dcloudio/uni-app";
import { objectToQuery } from '../../../until';
import { inboundFinish, stockInDetail } from '@/api/stockIn';
import Navigation from '../../../components/Navigation.vue';
import MaterialList from '../../../components/MaterialList.vue';
import WarehousingInfo from '../../../components/WarehousingInfo.vue';
import { onMounted } from 'vue';
import Navigation from '../../../components/Navigation.vue';
import {objectToQuery} from '../../../until';
// stockIn-putAway入库单入库编辑
const backUrl = ref('')
// 数据:路径参数
const pathParams = ref('')
// 标志:是否为编辑
const isEdit = ref('')
// 标志:区分页面 进入页面的状态 null新建 stockIn:入库编辑 stockIn-putAway入库单入库编辑
const flag = ref('')
// ref物料绑定
const materialRef = ref([])
// ref仓库信息绑定
const warehousingInfoRef = ref([])
// ref:选中的物料
const selectMaterialList = ref([])
const detailInfo = ref('')
// 数据:物料列表
const formData = ref([{ remark: '', material: [] }])
// 数据:仓库信息
@@ -69,7 +61,6 @@ const getMaterialList = () => {
}
// 方法:获取详情 - 更新物料得值 获取唯一码后回来
const getDetailInfo = () => {
stockInDetail({ billNo: pathParams.value.billNo }).then((res) => {
@@ -102,32 +93,27 @@ const submitForm = () => {
billRemark: info.remark,
itemList: _.map(_materialInfo, (i) => ({ ...i.material }))
}
try {
inboundFinish(params).then((res) => {
uni.navigateTo({ url: backUrl.value });
})
} catch (err) {
console.log('入库单入库失败==》', err);
}
inboundFinish(params).then((res) => {
// stockIn
// /pages/warehousing/stockIn/components/detail
uni.navigateTo({
url: backUrl.value
});
console.log(res, '入库单入库');
})
}
// 数据:路径参数
onLoad((options) => {
console.log(options, 'options', _.includes(options?.type, 'stockIn'));
if (!options.billNo) {
uni.showToast({ title: '参数错误,无唯一码ID', icon: 'none' })
return
}
pathParams.value = options
// stockIn-putAway
// stockIn
const query = objectToQuery(pathParams.value)
backUrl.value = `/pages/warehousing/stockIn/components/detail${query}`
getDetailInfo()
flag.value = options.type
isEdit.value = _.includes(options?.type, 'stockIn')
})
onMounted(() => {