出库入库修改

This commit is contained in:
魏啾
2024-08-08 09:38:23 +08:00
parent d0cc82fdf5
commit 81f5c68fa7
5 changed files with 236 additions and 66 deletions

View File

@@ -13,7 +13,7 @@
</div>
</div>
</el-form-item>
<el-form-item label="出库类型" v-if="inTabValue == 'goods'">
<!-- <el-form-item label="出库类型" v-if="inTabValue == 'goods'">
<div class="shop_type_box">
<div class="item" v-for="(item, index) in shopTypes" :key="index"
:class="{ active: shopTypesActive == index }" @click="changeTypeEnum(index)">
@@ -34,11 +34,12 @@
</div>
</div>
</div>
</el-form-item>
</el-form-item> -->
<el-row>
<el-col :span="8" v-if="shopTypes[shopTypesActive].value == 'reject'">
<el-col :span="8">
<el-form-item label="供应商">
<el-select v-model="queryForm.purveyorId" placeholder="请选择供应商" style="width: 220px;">
<el-select clearable v-model="queryForm.purveyorId" placeholder="请选择供应商"
style="width: 220px;" @change="changeTypeEnum">
<el-option :label="item.purveyorName" :value="item.id" v-for="item in purveyorList"
:key="item.id"></el-option>
</el-select>
@@ -88,11 +89,15 @@
</el-form-item>
</el-col>
</el-row>
<el-form-item>
<!-- <el-form-item>
<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>
</el-form-item> -->
<el-autocomplete v-model="autocompletename" :fetch-suggestions="querySearchAsync"
:value-key="inTabValue == 'goods' ? 'name' : 'conName'" :placeholder="inTabValue == 'goods'?'商品搜索':'耗材搜索'" @select="handleSelect"
style="width: 500px;"></el-autocomplete>
</el-form>
</div>
<div class="head-container">
@@ -137,7 +142,7 @@
</el-table-column> -->
<el-table-column label="操作" width="80">
<template v-slot="scope">
<el-button type="text" @click="tableData.list.splice(scope.$index, 1)">删除</el-button>
<el-button type="text" @click="tableData.list.splice(scope.$index, 1),consCountTotal($event, scope.row, 'stockNumber')">删除</el-button>
</template>
</el-table-column>
</el-table>
@@ -179,7 +184,7 @@
</el-table-column>
<el-table-column label="操作" width="80">
<template v-slot="scope">
<el-button type="text" @click="tableData.list.splice(scope.$index, 1)">删除</el-button>
<el-button type="text" @click="tableData.list.splice(scope.$index, 1),consCountTotal($event, scope.row, 'stockNumber')">删除</el-button>
</template>
</el-table-column>
</el-table>
@@ -209,7 +214,8 @@
import dayjs from 'dayjs'
import shopList from './components/shopList'
import ConsumableList from './components/consumableList'
import { tbShopPurveyorGet, tbProductStockOperateOutAndOn, stockInOut } from '@/api/invoicing'
import { tbShopPurveyorGet, tbProductStockOperateOutAndOn, stockInOut, tbConsInfoGet, tbProductlist } from '@/api/invoicing'
import { formatDecimal } from '@/utils'
export default {
components: {
@@ -232,7 +238,7 @@ export default {
type: 'out'
}
],
shopTypesActive: 0,
shopTypesActive: 1,
shopTypes: [
{
label: '供应商退货',
@@ -284,7 +290,10 @@ export default {
tableData: {
list: []
},
showResult: false
showResult: false,
autocompletename: '',
restaurants: [],
timeout: null
}
},
mounted() {
@@ -292,10 +301,50 @@ export default {
this.tbShopPurveyorGet()
},
methods: {
async querySearchAsync(queryString, cb) {//快捷搜索
let res = null
if (this.inTabValue == 'goods') {
res = await tbProductlist({
page: 0,
size: 20,
name: queryString ? queryString : '',
shopId: localStorage.getItem('shopId'),
sort: 'id',
})
} else {
res = await tbConsInfoGet({
page: 0,
size: 20,
shopId: localStorage.getItem('shopId'),
conName: queryString ? queryString : ''
})
}
this.restaurants = res.content
if (res.content.length == 0) {//给个提示没有搜到
this.$message('无此商品');
return false
}
var uniqueArray = this.restaurants.filter(item1 =>
!this.tableData.list.some(item2 => item2.productId == item1.id)
);
clearTimeout(this.timeout);
this.timeout = setTimeout(() => {
cb(uniqueArray);
}, 1000 * Math.random());
},
handleSelect(item) {//选定后清空
this.autocompletename = ''
if (this.inTabValue == 'goods') {
this.selectShop([item])
} else {
this.selectConsumable([item])
}
},
// 切换入库内容
tabChange(value, type) {
this.inTabValue = value
this.shopTypesActive = 0
this.shopTypesActive = 1
this.resetHandle()
this.queryForm.type = type
},
@@ -347,6 +396,19 @@ export default {
},
// 提交
submitHandle() {
if (this.tableData.list.length == 0) {
switch (this.inTabValue) {
case 'goods':
this.$message('请先选择商品入!');
break;
case 'consumable':
this.$message('请先选择耗材!');
break;
default:
break;
}
return false
}
this.$refs.queryForm.validate(async valid => {
if (valid) {
try {
@@ -370,6 +432,8 @@ export default {
}
this.queryFormLoading = false
this.showResult = true
this.$refs.shopList.clearSelection()//清除选项
this.$refs.ConsumableList.clearSelection()//清除选项
} catch (error) {
console.log(error)
this.queryFormLoading = false
@@ -379,13 +443,14 @@ export default {
},
// 选择耗材
selectConsumable(res) {
this.tableData.list = res.map(item => {
let arr = 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
})
this.tableData.list = [...this.tableData.list, ...arr]
},
// 选择商品
selectShop(res) {
@@ -402,8 +467,7 @@ export default {
})
})
})
console.log(arr)
this.tableData.list = arr
this.tableData.list = [...this.tableData.list, ...arr]
},
// 初始化
resetHandle() {
@@ -419,8 +483,14 @@ export default {
},
// 切换类型
changeTypeEnum(index) {
this.shopTypesActive = index
this.queryForm.type = this.shopTypes[index].value
if (this.queryForm.purveyorId) {
this.shopTypesActive = 0
} else {
this.shopTypesActive = 1
}
this.queryForm.type = this.shopTypes[this.shopTypesActive].value
// this.shopTypesActive = index
// this.queryForm.type = this.shopTypes[index].value
},
// 获取供应商列表
async tbShopPurveyorGet() {