Commit 98c31506 authored by Damon's avatar Damon

refactor: 完工页-仓配库存优化

parent d8548a31
...@@ -44,7 +44,7 @@ let partsApiFun = function (vm) { ...@@ -44,7 +44,7 @@ let partsApiFun = function (vm) {
/** /**
* 查询自己的物料仓 * 查询自己的物料仓
*/ */
let getMyReserve = async (params = {}) => await vm.$u.get(parts + vm.vuex_token + '/items/reserve', params); let getMyReserve = async (params = {}) => await vm.$u.get(parts + vm.vuex_token + '/items/v2/reserve', params);
/** /**
* 查询工单的配件明细 * 查询工单的配件明细
*/ */
......
...@@ -55,6 +55,10 @@ export default { ...@@ -55,6 +55,10 @@ export default {
type: String, type: String,
default: '', default: '',
}, },
orderNumber: {
type: String,
default: '',
},
categoryId: { categoryId: {
type: String, type: String,
default: '', default: '',
...@@ -89,10 +93,28 @@ export default { ...@@ -89,10 +93,28 @@ export default {
this.getWorkOrderParts() this.getWorkOrderParts()
}, },
methods: { methods: {
// 获取最新库存
getWorkOrderParts() { getWorkOrderParts() {
// this.lists = JSON.parse(this.dataValue) || [] const lists = this.dataValue ? JSON.parse(this.dataValue).filter(v => v.name) : []
const lists = this.dataValue ? JSON.parse(this.dataValue) : [] this.$u.api
this.lists = lists.filter(v => v.name) .getMyReserve({
categoryId: this.categoryId,
brandId: this.brandId,
orderNumber: this.orderNumber
})
.then((res) => {
if (res.code === 200) {
const data = res.data || []
this.lists = lists.map(v => {
const row = data.find(item => item.skuId === v.skuId)
if (row) {
v.max = row.stock + Number(row.useStock)
}
return v
})
console.log("this.lists", this.lists)
}
})
}, },
partsChange(val, index) { partsChange(val, index) {
this.$set(this.lists[index], 'quantity', val) this.$set(this.lists[index], 'quantity', val)
...@@ -116,7 +138,7 @@ export default { ...@@ -116,7 +138,7 @@ export default {
valChange(val) { valChange(val) {
if (val) { if (val) {
val.forEach((v) => { val.forEach((v) => {
const index = this.lists.findIndex((k) => k.part_id === v.part_id) const index = this.lists.findIndex((k) => k.skuId === v.skuId)
if (index < 0) { if (index < 0) {
this.lists.push(v) this.lists.push(v)
} else { } else {
...@@ -130,7 +152,7 @@ export default { ...@@ -130,7 +152,7 @@ export default {
}, },
toParts() { toParts() {
uni.navigateTo({ uni.navigateTo({
url: `/pages/order/parts?workOrderId=${this.orderId}&brandId=${this.brandId}&categoryId=${this.categoryId}`, url: `/pages/order/parts?workOrderId=${this.orderId}&brandId=${this.brandId}&categoryId=${this.categoryId}&orderNumber=${this.orderNumber}`,
}) })
}, },
}, },
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
<view class="right-content-name u-line-2">{{ info.name }}</view> <view class="right-content-name u-line-2">{{ info.name }}</view>
<view class="right-content-desc u-line-2">{{ info.remark }}</view> <view class="right-content-desc u-line-2">{{ info.remark }}</view>
<view class="u-flex right-content-opera"> <view class="u-flex right-content-opera">
<view class="no" v-if="info.stock"> <view class="no" v-if="info.max">
可用{{ info.stock }}件 可用{{ info.max }}件
</view> </view>
<view class="num"> <view class="num">
<u-number-box v-show="!info.disabled" v-model="info.quantity" :min="info.min || 0" :max="info.max || info.quantity" @change="numChange"></u-number-box> <u-number-box v-show="!info.disabled" v-model="info.quantity" :min="info.min || 0" :max="info.max || info.quantity" @change="numChange"></u-number-box>
......
...@@ -246,6 +246,7 @@ ...@@ -246,6 +246,7 @@
:categoryId="categoryId" :categoryId="categoryId"
:brandId="brandId" :brandId="brandId"
:order-id="orderId" :order-id="orderId"
:orderNumber="orderNumber"
:groupIndex="groupIndex" :groupIndex="groupIndex"
:itemIndex="itemIndex" :itemIndex="itemIndex"
:item="item" :item="item"
...@@ -445,6 +446,7 @@ export default { ...@@ -445,6 +446,7 @@ export default {
orderId: 0, orderId: 0,
categoryId: 0, categoryId: 0,
brandId: 0, brandId: 0,
orderNumber: '',
orderServiceType: '', orderServiceType: '',
inGuaranteePeriod: '', inGuaranteePeriod: '',
partnerCompanyId: '', partnerCompanyId: '',
...@@ -705,12 +707,16 @@ export default { ...@@ -705,12 +707,16 @@ export default {
name: group.name, name: group.name,
items: ele, items: ele,
} }
if (ele.fieldsName === 'orderSpareParts') {
const index = errArr.findIndex(v => v.name === '备件信息' || v.name === '物料信息')
if (index > -1) return
}
errArr.push(errGroup) errArr.push(errGroup)
} }
}) })
}) })
}) })
// 图片分组
const result = errArr.reduce((groups, item) => { const result = errArr.reduce((groups, item) => {
let groupFound = groups.find((arrItem) => item.name === arrItem.name) let groupFound = groups.find((arrItem) => item.name === arrItem.name)
if (groupFound) { if (groupFound) {
...@@ -783,7 +789,7 @@ export default { ...@@ -783,7 +789,7 @@ export default {
}) })
} else { } else {
this.$refs.uToast.show({ this.$refs.uToast.show({
title: res.message || res.data, title: res.data || res.message,
type: 'error', type: 'error',
}) })
} }
......
...@@ -98,6 +98,7 @@ export default { ...@@ -98,6 +98,7 @@ export default {
this.workOrderId = parseInt(e.workOrderId) this.workOrderId = parseInt(e.workOrderId)
this.categoryId = parseInt(e.categoryId) this.categoryId = parseInt(e.categoryId)
this.brandId = parseInt(e.brandId) this.brandId = parseInt(e.brandId)
this.orderNumber = e.orderNumber
this.getReserve() this.getReserve()
}, },
methods: { methods: {
...@@ -106,16 +107,18 @@ export default { ...@@ -106,16 +107,18 @@ export default {
.getMyReserve({ .getMyReserve({
categoryId: this.categoryId, categoryId: this.categoryId,
brandId: this.brandId, brandId: this.brandId,
orderNumber: this.orderNumber,
keyword: this.keyword, keyword: this.keyword,
}) })
.then((res) => { .then((res) => {
if (res.code === 200) { if (res.code === 200) {
const data = res.data || [] const data = res.data || []
this.lists = data.map((v) => { this.lists = data.map((v) => {
const max = v.stock + Number(v.useStock)
v.min = 1 v.min = 1
v.max = v.stock
v.checked = false v.checked = false
v.quantity = v.stock v.quantity = max
v.max = max
const images = v.images ? v.images.split(',') : [] const images = v.images ? v.images.split(',') : []
v.images = images[0] v.images = images[0]
return v return v
...@@ -147,9 +150,8 @@ export default { ...@@ -147,9 +150,8 @@ export default {
.map((v) => { .map((v) => {
return { return {
name: v.name, name: v.name,
part_id: v.skuId, skuId: v.skuId,
quantity: v.quantity, quantity: v.quantity,
max: v.max,
cost: v.cost || 0, cost: v.cost || 0,
} }
}) })
......
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