退货单80%

This commit is contained in:
xiaofajia 2024-11-28 17:35:52 +08:00
parent 594ccdba39
commit 4ec9f5be26
4 changed files with 416 additions and 0 deletions

View File

@ -34,3 +34,12 @@ export function getMapBySoIdAndQuery(id, query){
method: 'get'
})
}
// 根据供应商查询该供应商采购过的配件 分页
export function getSoBySupplier(params){
return request({
url: preUrl + "/getSoBySupplier",
method: 'get',
params
})
}

View File

@ -0,0 +1,150 @@
<template>
<div>
<!-- 搜索 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
<el-form-item label="退货时间" prop="searchTimeArray">
<el-date-picker
value-format="yyyy-MM-dd HH:mm:ss"
v-model="queryParams.searchTimeArray"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="供应商" prop="supplierId">
<SupplierChoose v-model="supplier"/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 操作 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-download" size="mini"
>导出
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">
新增
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch"></right-toolbar>
</el-row>
<!-- 表格 -->
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="序号" align="center" width="55">
<template scope="scope">
<span>{{ scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column label="单号" align="center" prop="soNo" width="200"/>
<el-table-column label="数量" align="center" prop="itemCount" width="150"/>
<el-table-column label="金额" align="center" prop="totalPrice" width="150"/>
<el-table-column label="供应商" align="center" prop="supplierName"/>
<el-table-column label="退货时间" align="center" prop="soTime"
width="150"/>
<el-table-column label="操作" fixed="right" width="180" align="center">
<template v-slot="scope">
<el-button size="mini" type="text" icon="el-icon-view" @click="handleShow(scope.row)"
>查看
</el-button>
<el-button size="mini" type="text" icon="el-icon-close" @click="handleVoidSo(scope.row)"
>作废
</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleVoidSo(scope.row)"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<pagination @pagination="getReturnList" style="margin-bottom: 3rem" v-show="total > 0" :total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
/>
<SoReturnForm ref="soReturnRef" @success="getReturnList"/>
</div>
</template>
<script>
import SupplierChoose from "@/views/repair/Components/SupplierChoose.vue";
import StaffChoose from "@/views/repair/Components/StaffChoose.vue";
import CorpChoose from "@/views/repair/Components/CorpChoose.vue";
import SoReturnForm from "@/views/repair/stockOperate/form/SoReturnForm.vue";
import {getRepairSoPage} from "@/api/repair/stockOperate/stockOperate";
export default {
name: "SoReturn",
components: {SoReturnForm, CorpChoose, StaffChoose, SupplierChoose},
data() {
return {
queryParams: {
pageNo: 1,
pageSize: 10,
searchTimeArray: [],
supplierId: null,
soType: "06"
},
showSearch: true,
list: [],
total: 0,
loading: false,
supplier: null
}
},
watch:{
'supplier'(val){
if (val){
this.queryParams.supplierId = val.id
}else {
this.resetQuery()
}
}
},
mounted() {
this.getReturnList()
},
methods: {
async getReturnList() {
try {
this.loading = true
const res = await getRepairSoPage(this.queryParams)
this.list = res.data.records
this.total = res.data.total
}finally {
this.loading = false
}
},
handleQuery() {
this.queryParams.pageNo = 1
this.getReturnList()
},
resetQuery() {
this.queryParams = {
pageNo: 1,
pageSize: 10,
searchTimeArray: [],
supplierId: null,
soType: "06"
}
this.supplier = null
this.handleQuery()
},
handleAdd(){
this.$refs.soReturnRef.open()
}
}
}
</script>
<style scoped lang="scss">
</style>

View File

@ -4,6 +4,9 @@
<el-tab-pane label="采购单据" name="purchase">
<SoIndex :so-by-type="soByType"/>
</el-tab-pane>
<el-tab-pane label="退货单据" name="returnOrder">
<SoReturn />
</el-tab-pane>
<el-tab-pane label="急件单据" name="urgentPurchase">
<SoIndex :so-by-type="soByType" :goods-yes="true"/>
</el-tab-pane>
@ -26,10 +29,12 @@ import SoInfo from "@/views/repair/stockOperate/Components/SoInfo.vue";
import SoIndex from "@/views/repair/stockOperate/Components/SoIndex.vue";
import SoVoid from "@/views/repair/stockOperate/Components/SoVoid.vue";
import SoiTable from "@/views/repair/stockOperate/Components/SoiTable.vue";
import SoReturn from "@/views/repair/stockOperate/Components/SoReturn.vue";
export default {
name: "InStock",
components: {
SoReturn,
SoiTable,
SoVoid,
SoIndex,

View File

@ -0,0 +1,252 @@
<template>
<div>
<el-dialog title="新增退货单" :visible.sync="dialogVisible" width="80%" v-dialogDrag append-to-body>
<el-form :inline="true">
<el-form-item label="供应商">
<SupplierChoose v-model="chooseSupplier" />
</el-form-item>
<el-form-item label="关键字">
<el-input v-model="queryParams.query" placeholder="名称、编码、规格"/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" @selection-change="selectRow" ref="showTable">
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="商品名称" prop="wares.name" align="center" />
<el-table-column label="商品编码" prop="wares.code" align="center" />
<el-table-column label="规格型号" prop="wares.model" align="center" />
<el-table-column label="库存数量" prop="wares.stock" align="center" />
<el-table-column label="计量单位" prop="wares.unit" align="center">
<template slot-scope="scope">
<dict-tag :value="scope.row.wares.unit" :type="DICT_TYPE.REPAIR_UNIT" />
</template>
</el-table-column>
<el-table-column label="所属仓库" prop="wares.warehouse" align="center">
<template slot-scope="scope">
{{getWarehouseName(scope.row.wares.warehouse)}}
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<pagination @pagination="getListBySupplier" style="margin-bottom: 3rem" v-show="total > 0" :total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
/>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitBefore" :disabled="!selectRows || selectRows.length === 0">确定</el-button>
<el-button type="primary" @click="dialogVisible = false">取消</el-button>
</div>
</el-dialog>
<el-dialog title="设置数量" :visible.sync="settingDialog" width="60%" v-dialogDrag append-to-body>
<el-table :data="chooseRows" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="序号" align="center" width="55">
<template scope="scope">
<span>{{ scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column label="名称" prop="wares.name" align="center" />
<el-table-column label="库存数量" prop="wares.stock" align="center" />
<el-table-column label="退货数量" prop="wares.returnCount" align="center">
<template slot-scope="scope">
<el-input-number style="width: 15rem" v-model="scope.row.wares.returnCount" :max="scope.row.wares.stock" :min="0" />
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<el-button type="text" size="mini" icon="el-icon-edit-delete" @click="removeRow(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit" :disabled="!chooseRows || chooseRows.length === 0">确定</el-button>
<el-button type="primary" @click="settingDialog = false">取消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import SupplierChoose from "@/views/repair/Components/SupplierChoose.vue";
import {getSoBySupplier} from "@/api/repair/stockOperate/stockOperateItem";
import {getBaseWarehouseList} from "@/api/base/warehouse";
import {createUniqueCodeByHead} from "@/utils/createUniqueCode";
import {createRepairSo} from "@/api/repair/stockOperate/stockOperate";
export default {
name: "SoReturnForm",
components: {SupplierChoose},
data(){
return{
dialogVisible: false,
formData:{
supplierId: null,
supplierName: null,
},
list:[],
loading: false,
queryParams:{
pageNo: 1,
pageSize: 10,
supplierId: null,
query: null
},
total: 0,
warehouseList: [],
chooseSupplier: null,
selectRows: [],
isRefresh: false,
settingDialog: false,
chooseRows: []
}
},
watch:{
'chooseSupplier'(val){
if (val){
this.queryParams.supplierId = val.id
this.formData.supplierId = val.id
this.formData.supplierName = val.name
this.getListBySupplier()
}else {
this.resetQueryParams()
}
}
},
methods:{
removeRow(row){
const index = this.chooseRows.findIndex(item => item.id === row.id)
this.chooseRows.splice(index, 1)
},
selectRow(row){
//
const oldIds = this.selectRows.map(item => item.id)
const newData = row.filter(item => !oldIds.includes(item.id))
this.selectRows = [...this.selectRows, ...newData]
//
if (!this.isRefresh){
const selectIds = row.map(item => item.id)
const allIds = this.$refs.showTable.data.map(item => item.id)
const delIds = allIds.filter(item => !selectIds.includes(item))
if (delIds && delIds.length > 0){
this.selectRows = this.selectRows.filter(item => !delIds.includes(item.id))
}
}else {
this.isRefresh = false
}
},
handleQuery(){
this.isRefresh = true
this.queryParams.pageNo = 1
this.getListBySupplier()
},
resetQuery(){
this.resetQueryParams()
},
getWarehouseName(id){
if (!this.warehouseList || this.warehouseList.length === 0){
this.getWarehouseList()
}
if (id){
const index = this.warehouseList.findIndex(item => item.id === id)
return this.warehouseList[index].name
}
return ""
},
async getWarehouseList(){
const response = await getBaseWarehouseList()
this.warehouseList = response.data
},
async getListBySupplier(){
if (this.queryParams.supplierId){
try {
this.loading = true
const res = await getSoBySupplier(this.queryParams)
this.list = res.data.records
this.total = res.data.total
this.$nextTick(() => {
this.$refs.showTable.clearSelection();
this.selectRows.forEach(row => {
const matchingRow = this.list.find(item => item.id === row.id);
if (matchingRow) {
this.$refs.showTable.toggleRowSelection(matchingRow, true);
}
});
})
}finally {
this.loading = false
}
}else {
this.resetQueryParams()
this.$modal.msgWarning("请先选择供应商")
}
},
async open(){
this.resetFormData()
await this.getWarehouseList()
this.dialogVisible = true
},
resetFormData(){
this.chooseSupplier = null
this.formData = {}
this.resetForm("formRef")
},
submitBefore(){
this.chooseRows = this.selectRows.map(item => {
const newItem = JSON.parse(JSON.stringify(item));
newItem.wares.returnCount = 0;
return newItem;
});
this.settingDialog = true
},
async submit(){
try {
const flag = this.chooseRows.filter(item => item.wares.returnCount === 0)
if (flag && flag.length > 0){
this.$modal.msgError(`${flag[0].wares.name}的退货数量为0`)
return
}
this.formData.soType = "06"
this.formData.soNo = createUniqueCodeByHead("TH")
this.formData.itemCount = this.chooseRows.length
this.formData.totalPrice = this.chooseRows.map(item => item.wares.purPrice || 0).reduce((x, y) => x + y, 0)
this.formData.goodsList = this.chooseRows.map(item => {
return {
soiType: "06",
goodsId: item.wares.id,
wareId: item.wares.warehouse,
goodsCount: item.wares.returnCount,
goodsPrice: item.wares.purPrice,
}
})
await createRepairSo(this.formData)
this.dialogVisible = false
this.settingDialog = false
this.$modal.msgSuccess("新增成功")
this.$emit('success')
}catch{}
},
resetQueryParams(){
this.formData.supplierId = null
this.formData.supplierName = null
this.queryParams = {
pageNo: 1,
pageSize: 10,
supplierId: null,
query: null
}
this.list = []
this.total = 0
this.chooseSupplier = null
this.selectRows = []
this.isRefresh = false
}
}
}
</script>
<style scoped lang="scss">
</style>