优化操作出入库耗材多选

This commit is contained in:
gyq
2024-07-08 11:21:50 +08:00
parent 10e3af1cb3
commit 36c57f5ad1
6 changed files with 124 additions and 58 deletions

View File

@@ -5,7 +5,7 @@
<el-form-item label="入库内容">
<div class="shop_type_box">
<div class="item" v-for="item in inTabs" :key="item.value"
:class="{ active: inTabValue == item.value }" @click="tabChange(item.value)">
:class="{ active: inTabValue == item.value }" @click="tabChange(item.value, item.type)">
<div class="s_title">{{ item.label }}</div>
<div class="active_dot">
<i class="el-icon-check"></i>
@@ -89,7 +89,7 @@
</el-col>
</el-row>
<el-form-item>
<el-button type="primary" @click="$refs.ConsumableList.show()"
<el-button type="primary" @click="$refs.ConsumableList.show(tableData.list)"
v-if="inTabValue == 'consumable'">选择耗材</el-button>
<el-button type="primary" @click="$refs.shopList.show(tableData.list)" v-else>选择商品</el-button>
</el-form-item>
@@ -113,14 +113,14 @@
<el-table-column label="进价">
<template v-slot="scope">
<el-input-number v-model="scope.row.price" :min="0" controls-position="right"
@change="e => { queryForm.totalAmount = formatDecimal(e * scope.row.stockNumber) }"></el-input-number>
@change="consCountTotal()"></el-input-number>
<div class="tips">原价{{ scope.row.costPrice }}/{{ scope.row.conUnit }}</div>
</template>
</el-table-column>
<el-table-column label="数量">
<template v-slot="scope">
<el-input-number v-model="scope.row.stockNumber" :min="0" controls-position="right"
@change="e => { queryForm.totalAmount = formatDecimal(e * scope.row.price) }"></el-input-number>
@change="consCountTotal()"></el-input-number>
<div class="tips">入库前{{ scope.row.number }}{{ scope.row.conUnit }}
</div>
</template>
@@ -226,11 +226,13 @@ export default {
inTabs: [
{
label: '商品入库',
value: 'goods'
value: 'goods',
type: 'purveyor'
},
{
label: '耗材入库',
value: 'consumable'
value: 'consumable',
type: 'in'
}
],
shopTypesActive: 0,
@@ -294,16 +296,26 @@ export default {
},
methods: {
// 切换入库内容
tabChange(value) {
tabChange(value, type) {
this.inTabValue = value
this.shopTypesActive = 0
this.queryForm.type = type
},
// 计算耗材总价
consCountTotal() {
let zong = 0
this.tableData.list.forEach(ele => {
zong += ele.price * ele.stockNumber
})
this.queryForm.totalAmount = formatDecimal(zong)
},
// 计算商品总价
modifyPrice() {
let zong = 0
this.tableData.list.forEach(ele => {
zong += ele.costPrice * ele.number
})
this.queryForm.totalAmount = parseFloat(zong.toFixed(2))
this.queryForm.totalAmount = formatDecimal(zong)
},
// 提交
submitHandle() {
@@ -317,17 +329,12 @@ export default {
await tbProductStockOperateOutAndOn(this.queryForm)
break;
case 'consumable':
const con = { ...this.tableData.list[0] }
await stockInOut({
accountsPayable: this.queryForm.totalAmount,
actualPayment: this.queryForm.paidAmount,
conInfoId: con.id,
paymentTime: this.queryForm.paidAt,
price: con.price,
stockNumber: con.stockNumber,
supplierId: this.queryForm.purveyorId,
type: 'in'
})
this.queryForm.accountsPayable = this.queryForm.totalAmount
this.queryForm.actualPayment = this.queryForm.paidAmount
this.queryForm.paymentTime = this.queryForm.paidAt
this.queryForm.supplierId = this.queryForm.purveyorId
this.queryForm.list = this.tableData.list
await stockInOut(this.queryForm)
break;
default:
break;
@@ -343,12 +350,13 @@ export default {
},
// 选择耗材
selectConsumable(res) {
const n_res = { ...res }
res.costPrice = n_res.price
res.number = n_res.stockNumber - n_res.stockConsume
res.stockNumber = 0
this.tableData.list = [res]
this.queryForm.totalAmount = formatDecimal(res.price * res.stockNumber)
this.tableData.list = res.map(item => {
item.number = formatDecimal(item.stockNumber - item.stockConsume, 2, true)
item.stockNumber = 0
item.costPrice = item.price
item.conInfold = item.id
return item
})
},
// 选择商品
selectShop(res) {
@@ -373,6 +381,7 @@ export default {
this.showResult = false
this.queryForm = { ...this.resetForm }
this.tableData.list = []
this.$refs.queryForm.resetFields()
},
// 切换类型
changeTypeEnum(index) {