入库流程对接完毕
This commit is contained in:
147
pages/warehousing/StockIn/components/detail.vue
Normal file
147
pages/warehousing/StockIn/components/detail.vue
Normal file
@@ -0,0 +1,147 @@
|
||||
<template>
|
||||
<!-- 自定义导航栏 -->
|
||||
<navigation :title="pathParams.billNo">
|
||||
<template #right>
|
||||
<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" />
|
||||
</view>
|
||||
</template>
|
||||
</Navigation>
|
||||
<!-- 详情信息 -->
|
||||
<detail-info type="stockIn" :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>
|
||||
</template>
|
||||
<script setup>
|
||||
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 DetailInfo from '../../../components/DetailInfo.vue';
|
||||
import Navigation from '../../../components/Navigation.vue';
|
||||
|
||||
// 数据:路径参数
|
||||
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
|
||||
})
|
||||
}
|
||||
|
||||
// 打印
|
||||
const onPrinter = () => {
|
||||
|
||||
}
|
||||
const toObsolete = () => {
|
||||
const params = {
|
||||
billNo: pathParams.value?.billNo,
|
||||
billType: '5'
|
||||
}
|
||||
inboundBillVoid(params).then((res) => {
|
||||
// /pages/warehousing/stockIn/my
|
||||
uni.navigateTo({
|
||||
url: `/pages/warehousing/stockIn/my`
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
const setDetailInfoToStorage = (type) => {
|
||||
uni.setStorageSync('app_warehousing', [{
|
||||
deptName: detailInfo.value?.warehouseName,
|
||||
deptCode: detailInfo.value?.warehouseCode,
|
||||
}])
|
||||
uni.setStorageSync('app_storageArea', [{
|
||||
deptName: detailInfo.value?.areaName,
|
||||
deptCode: detailInfo.value?.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_material', material)
|
||||
uni.setStorageSync('app_material_select_list', materialSelectList)
|
||||
} else {
|
||||
uni.setStorageSync('app_material', detailInfo.value?.itemList)
|
||||
}
|
||||
uni.setStorageSync('app_billRemark', detailInfo.value?.billRemark,)
|
||||
|
||||
}
|
||||
// 按钮:入库单入库
|
||||
const toPutAway = () => {
|
||||
setDetailInfoToStorage('1')
|
||||
uni.navigateTo({
|
||||
url: `/pages/warehousing/stockIn/components/inbound?billNo=${pathParams.value.billNo}`
|
||||
});
|
||||
}
|
||||
// 编辑
|
||||
const onEdit = () => {
|
||||
setDetailInfoToStorage()
|
||||
const query = objectToQuery(pathParams.value)
|
||||
let url = `/pages/warehousing/stockIn/create${query}`
|
||||
uni.navigateTo({
|
||||
url: url
|
||||
});
|
||||
}
|
||||
|
||||
// 接收路径参数:billNo
|
||||
onLoad((options) => {
|
||||
if (!options.billNo) {
|
||||
uni.showToast({ title: '参数错误,无唯一码ID', icon: 'none' })
|
||||
return
|
||||
}
|
||||
pathParams.value = options
|
||||
getDetailInfo()
|
||||
})
|
||||
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
/* 底部按钮 */
|
||||
|
||||
|
||||
// 底部按钮
|
||||
.bottom {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
height: 60rpx;
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
|
||||
.uv-button-wrapper {
|
||||
width: 50%;
|
||||
border-radius: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.bottom1 {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
height: 60rpx;
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
// justify-content: center;
|
||||
width: 100%;
|
||||
|
||||
.uv-button-wrapper {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
158
pages/warehousing/StockIn/components/inbound.vue
Normal file
158
pages/warehousing/StockIn/components/inbound.vue
Normal file
@@ -0,0 +1,158 @@
|
||||
<!--点击入库单入库后的入库页面 -->
|
||||
<template>
|
||||
<view class="page">
|
||||
<!-- 仓库信息 - 仓库、存储区 -->
|
||||
<warehousing-info ref="warehousingInfoRef" :warehouseInfo="warehouseInfo" :pathParams="pathParams" />
|
||||
<!-- 物料列表 - 添加物料 -->
|
||||
<material-list ref="materialRef" :formData="formData" isEdit="5" backStr="stockIn" :pathParams="pathParams"
|
||||
:extendData="{ selectMaterialList }" />
|
||||
<!-- 底部操作栏 -->
|
||||
<view class="bottom">
|
||||
<uv-button type="primary" @click="submitForm">入库</uv-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
import _ from 'lodash';
|
||||
import { ref } from 'vue';
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app";
|
||||
import { inboundFinish, stockInDetail,inboundBillVoid } from '@/api/stockIn';
|
||||
import MaterialList from '../../../components/MaterialList.vue';
|
||||
import WarehousingInfo from '../../../components/WarehousingInfo.vue';
|
||||
import { onMounted } from 'vue';
|
||||
|
||||
// 数据:路径参数
|
||||
const pathParams = ref('')
|
||||
// 标志:是否为编辑
|
||||
const isEdit = ref('')
|
||||
// 标志:区分页面 进入页面的状态 null新建 stockIn:入库编辑 stockIn-putAway:入库单入库编辑
|
||||
const flag = ref('')
|
||||
|
||||
// ref:物料绑定
|
||||
const materialRef = ref([])
|
||||
// ref:仓库信息绑定
|
||||
const warehousingInfoRef = ref([])
|
||||
|
||||
const selectMaterialList = ref([])
|
||||
const detailInfo = ref('')
|
||||
|
||||
// 数据:物料列表
|
||||
const formData = ref([{ remark: '', material: [] }])
|
||||
// 数据:仓库信息
|
||||
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
|
||||
// 获取物料信息 - 有uniqueCode
|
||||
const material = uni.getStorageSync('app_material');
|
||||
formData.value.material = material
|
||||
// 获取物料信息 - 无uniqueCode
|
||||
const selectMaterial = uni.getStorageSync('app_material_select_list');
|
||||
selectMaterialList.value = selectMaterial
|
||||
// 获取入库单备注
|
||||
const billRemark = uni.getStorageSync('app_billRemark');
|
||||
warehouseInfo.value.remark = billRemark
|
||||
console.log('获取缓存', material, selectMaterial);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 方法:获取详情 - 更新物料得值 获取唯一码后回来
|
||||
const getDetailInfo = () => {
|
||||
stockInDetail({ billNo: pathParams.value.billNo }).then((res) => {
|
||||
setDetailInfoToStorage(res.data?.itemList)
|
||||
})
|
||||
}
|
||||
// 方法:存入缓存 - 更新物料得值 获取唯一码后回来
|
||||
const setDetailInfoToStorage = (val) => {
|
||||
// 过滤出有uniqueCode得值
|
||||
const material = _.filter(val, (i) => i?.uniqueCode && i.status == '0')
|
||||
const materialSelectList = _.filter(val, (i) => !i?.uniqueCode && i.status == '0')
|
||||
uni.setStorageSync('app_material', material)
|
||||
uni.setStorageSync('app_material_select_list', materialSelectList)
|
||||
getMaterialList()
|
||||
}
|
||||
// 入库:提交表单
|
||||
const submitForm = () => {
|
||||
const info = warehousingInfoRef.value.getWarehousingInfo()
|
||||
const materialInfo = materialRef.value.getMaterialList()
|
||||
// 过滤出已删除的物料
|
||||
const _materialInfo = _.filter(materialInfo, { isDelete: '0' })
|
||||
let params = {
|
||||
billType: '1',//0入库申请 1入库成功 2出库申请 3出库成功 4入库单已作废 5出库单已作废
|
||||
billNo: pathParams.value.billNo,
|
||||
warehouseCode: info.warehousing?.[0].deptCode || info.warehousing?.[0].deptId,
|
||||
warehouseName: info.warehousing?.[0].deptName,
|
||||
areaCode: info.storageArea?.[0].deptCode || info.storageArea?.[0].deptId,
|
||||
areaName: info.storageArea?.[0].deptName,
|
||||
remark: info.remark,
|
||||
billRemark: info.remark,
|
||||
itemList: _.map(_materialInfo, (i) => ({ ...i.material }))
|
||||
}
|
||||
|
||||
inboundFinish(params).then((res) => {
|
||||
// stockIn
|
||||
// /pages/warehousing/stockIn/components/detail
|
||||
uni.navigateTo({
|
||||
url: `/pages/warehousing/stockIn/components/detail?billNo=${pathParams.value.billNo}&type=stockIn`
|
||||
});
|
||||
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
|
||||
getDetailInfo()
|
||||
flag.value = options.type
|
||||
isEdit.value = _.includes(options?.type, 'stockIn')
|
||||
})
|
||||
// 修改标题:若有billNo传入 修改标题
|
||||
onShow(() => {
|
||||
if (pathParams.value.billNo) {
|
||||
uni.setNavigationBarTitle({ title: pathParams.value.billNo })
|
||||
}
|
||||
})
|
||||
onMounted(() => {
|
||||
getMaterialList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page {
|
||||
background: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* 底部按钮 */
|
||||
::v-deep .bottom {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
height: 60rpx;
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
|
||||
.uv-button-wrapper {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
206
pages/warehousing/StockIn/create.vue
Normal file
206
pages/warehousing/StockIn/create.vue
Normal file
@@ -0,0 +1,206 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<!-- 仓库信息 - 仓库、存储区 -->
|
||||
<warehousing-info ref="warehousingInfoRef" :warehouseInfo="warehouseInfo" :pathParams="pathParams" />
|
||||
<!-- 物料列表 - 添加物料 -->
|
||||
<material-list ref="materialRef" :formData="formData" isEdit="1" backStr="stockIn" :pathParams="pathParams" />
|
||||
<!-- 底部操作栏 -->
|
||||
<view class="bottom">
|
||||
<uv-button @click="scanCode">扫码添加</uv-button>
|
||||
<uv-button type="primary" @click="submitForm">提交</uv-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
import _ from 'lodash';
|
||||
import { ref } from 'vue';
|
||||
import { objectToQuery } from '../../until';
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app";
|
||||
import { addStockIn, stockInUpdate } from '@/api/stockIn';
|
||||
import { getMaterialUnique } from '@/api/uniqueCode';
|
||||
import MaterialList from '../../components/MaterialList.vue';
|
||||
import WarehousingInfo from '../../components/WarehousingInfo.vue';
|
||||
|
||||
|
||||
// 数据:路径参数
|
||||
const pathParams = ref('')
|
||||
// 标志:是否为编辑
|
||||
const isEdit = ref('')
|
||||
// 标志:区分页面 进入页面的状态 null新建 stockIn:入库编辑 stockIn-putAway:入库单入库编辑
|
||||
const flag = ref('')
|
||||
|
||||
// ref:物料绑定
|
||||
const materialRef = ref([])
|
||||
// ref:仓库信息绑定
|
||||
const warehousingInfoRef = ref([])
|
||||
|
||||
// 数据:物料列表
|
||||
const formData = ref([{ remark: '', material: [] }])
|
||||
// 数据:仓库信息
|
||||
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
|
||||
}
|
||||
getMaterialList();
|
||||
const scanResult = ref('')
|
||||
// 扫码添加
|
||||
const scanCode = () => {
|
||||
// 先校验是否支持扫码
|
||||
uni.scanCode({
|
||||
scanType: ['qrCode', 'barCode'], // 支持二维码 + 条形码
|
||||
success: (res) => {
|
||||
scanResult.value = res.result;
|
||||
if (res.result) {
|
||||
getMaterialUnique({ code: res.result }).then((response) => {
|
||||
console.log('物料内容:', response);
|
||||
if (`${response.code}` === '200') {
|
||||
const material = uni.getStorageSync('app_material');
|
||||
// 处理物料信息 合并
|
||||
const materialInfo = _.filter(material, { isDelete: '0' });
|
||||
console.log('materialInfo', materialInfo);
|
||||
const materialId = response.data?.[0]?.materialId;
|
||||
console.log('materialId', materialId);
|
||||
const idx = _.findIndex(materialInfo, (i) => i.materialId ? i.materialId == materialId : i.id == materialId);
|
||||
console.log('已选中是否有重复数据', idx);
|
||||
|
||||
if (idx != -1) {
|
||||
uni.showToast({
|
||||
title: '该物料已添加,请勿重复添加!',
|
||||
mask: true,
|
||||
icon: 'none',
|
||||
})
|
||||
} else {
|
||||
let _material = [...materialInfo, { ...response.data[0],uniqueCode:res.result }]
|
||||
console.log('新的物料数组', _material);
|
||||
formData.value.material = _material
|
||||
uni.setStorageSync('app_material', formData.value.material)
|
||||
}
|
||||
} else {
|
||||
console.log(response.code, 'response.code');
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({ title: '扫码失败', icon: 'none' });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 提交表单
|
||||
const submitForm = () => {
|
||||
const info = warehousingInfoRef.value.getWarehousingInfo()
|
||||
const materialInfo = materialRef.value.getMaterialList()
|
||||
|
||||
let params = {
|
||||
warehouseCode: info.warehousing?.[0].deptCode || info.warehousing?.[0].deptId,
|
||||
warehouseName: info.warehousing?.[0].deptName,
|
||||
areaCode: info.storageArea?.[0].deptCode || info.storageArea?.[0].deptId,
|
||||
areaName: info.storageArea?.[0].deptName,
|
||||
remark: info.remark,
|
||||
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,
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
// 数据:路径参数
|
||||
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(() => {
|
||||
if (pathParams.value.billNo) {
|
||||
uni.setNavigationBarTitle({ title: pathParams.value.billNo })
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page {
|
||||
background: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* 底部按钮 */
|
||||
::v-deep .bottom {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
height: 60rpx;
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
|
||||
.uv-button-wrapper {
|
||||
width: 50%;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.uv-button--info {
|
||||
background-color: #07c160;
|
||||
color: #fff;
|
||||
|
||||
}
|
||||
}
|
||||
</style>
|
||||
9
pages/warehousing/StockIn/my.vue
Normal file
9
pages/warehousing/StockIn/my.vue
Normal file
@@ -0,0 +1,9 @@
|
||||
<template>
|
||||
<search-list type="stockIn" :onDetail="onDetail" />
|
||||
</template>
|
||||
<script setup>
|
||||
import SearchList from '../../components/SearchList.vue';
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
10
pages/warehousing/StockIn/putaway.vue
Normal file
10
pages/warehousing/StockIn/putaway.vue
Normal file
@@ -0,0 +1,10 @@
|
||||
<!-- putAway:入库单入库 -->
|
||||
<template>
|
||||
<search-list type="stockIn-putAway" :onDetail="onDetail" :query="{ billType: '0' }" />
|
||||
</template>
|
||||
<script setup>
|
||||
import SearchList from '../../components/SearchList.vue';
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user