出库对接
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user