diff --git a/canteen/pages/delivery/apply.vue b/canteen/pages/delivery/apply.vue index 38b6ffa..a0f94a8 100644 --- a/canteen/pages/delivery/apply.vue +++ b/canteen/pages/delivery/apply.vue @@ -82,7 +82,8 @@ contents: [], warehouse_list: {}, enter_type: '', // 1 编辑,2 复用 - o_sn: '' + o_sn: '', + isStock: true } }, onLoad(e){ @@ -192,55 +193,79 @@ if(this.contents.length <= 0) { return this.$msg('您未选择物资') } - - var list = [] - for(var i;i< this.contents.length;i++) { - console.log('出库数量') - return - if(Number(this.contents[i].delivery_number.value) > this.contents[i].stock) { - this.$msg('库存数不足'+this.contents[i].stock) + + let list = this.contents.map(item => { + if(item.delivery_number.value == '') { + return this.$msg('请输入出库数量!') + } + + if(Number(item.delivery_number.value) > item.stock) { + console.log('循环几次') + uni.showModal({ + title: '温馨提示', + content: `物资:${item.material_name},仅剩${item.stock}单位库存,已超出您申请的数量,是否直接修改成出库${item.stock}单位`, + cancelColor: '#11D189', + confirmColor: '#FF0000', + success: result => { + if(result.confirm){ + this.isStock = true + item.delivery_number.value = item.stock + return { + m_id: item.material_id, + m_spec_id: item.spec_id, + purchase_id: item.purchase_id, + out_number: Number(item.delivery_number.value), + warehouse_id: item.order_id || 0, + tax_price: item.tax_price || '', // TODO 添加物资页面未返回价格,默认空 + non_tax_price: item.non_tax_price || '', + m_unit_id: item.m_unit_id || 0 + } + }else { + item.delivery_number.value = '' + this.isStock = true + return { + m_id: item.material_id, + m_spec_id: item.spec_id, + purchase_id: item.purchase_id, + out_number: Number(item.delivery_number.value), + warehouse_id: item.order_id || 0, + tax_price: item.tax_price || '', // TODO 添加物资页面未返回价格,默认空 + non_tax_price: item.non_tax_price || '', + m_unit_id: item.m_unit_id || 0 + } + } + } + }) + this.isStock = false return + }else { + return { + m_id: item.material_id, + m_spec_id: item.spec_id, + purchase_id: item.purchase_id, + out_number: Number(item.delivery_number.value) || 1, + warehouse_id: item.order_id || 0, + tax_price: item.tax_price || '', // TODO 添加物资页面未返回价格,默认空 + non_tax_price: item.non_tax_price || '', + m_unit_id: item.m_unit_id || 0 + } } - list.push({ - m_id: this.contents[i].material_id, - m_spec_id: this.contents[i].spec_id, - purchase_id: this.contents[i].purchase_id, - out_number: Number(this.contents[i].delivery_number.value) || 1, - warehouse_id: this.contents[i].order_id || 0, - tax_price: this.contents[i].tax_price || '', // TODO 添加物资页面未返回价格,默认空 - non_tax_price: this.contents[i].non_tax_price || '', - m_unit_id: this.contents[i].m_unit_id || 0 - }) - } - // let list = this.contents.map(item => { - // if(Number(item.delivery_number.value) > item.stock) { - // this.$msg('库存数不足'+item.stock) - // return - // } - // return { - // m_id: item.material_id, - // m_spec_id: item.spec_id, - // purchase_id: item.purchase_id, - // out_number: Number(item.delivery_number.value) || 1, - // warehouse_id: item.order_id || 0, - // tax_price: item.tax_price || '', // TODO 添加物资页面未返回价格,默认空 - // non_tax_price: item.non_tax_price || '', - // m_unit_id: item.m_unit_id || 0 - // } - // }); + }); - console.log('==========',list) - let _api = this.API.API_CANTEEN_WAREHOUSEOUT; - if(this.enter_type == 1){ - _api = this.API.API_EDITOUTORDER; + console.log(this.isStock) + if(this.isStock) { + let _api = this.API.API_CANTEEN_WAREHOUSEOUT; + if(this.enter_type == 1){ + _api = this.API.API_EDITOUTORDER; + } + let state = ['待确认', '已确认'][_t]; // 传入状态 + this.$http(_api, { + data: list, + state: state + }).then(res => { + this.$msg('操作成功').then(() => this.$toBack()); + }) } - let state = ['待确认', '已确认'][_t]; // 传入状态 - this.$http(_api, { - data: list, - state: state - }).then(res => { - this.$msg('操作成功').then(() => this.$toBack()); - }) } } }