This commit is contained in:
xuyuncong 2025-10-24 16:59:22 +08:00
parent 780f394407
commit cf441fddf9
3 changed files with 246 additions and 41 deletions

View File

@ -14,7 +14,7 @@ export function createRepairSo(data){
// 分页 // 分页
export function getRepairSoPage(params){ export function getRepairSoPage(params){
return request({ return request({
url: preUrl + "/page", url: preUrl + "/page-with-items",
method: "get", method: "get",
params params
}) })

View File

@ -80,18 +80,26 @@
<el-card class="amount-card" v-if="soByType && !goodsYes"> <el-card class="amount-card" v-if="soByType && !goodsYes">
<div class="amount-info"> <div class="amount-info">
<span class="amount-label">采购总金额</span> <span class="amount-label">采购总金额</span>
<span class="amount-value">¥{{ purchaseAmount.toFixed(2) }}</span> <span class="amount-value">¥{{ (purchase && purchase.purchaseAmount ? purchase.purchaseAmount : 0).toFixed(2) }}</span>
</div>
<div class="amount-info">
<span class="amount-label">采购数量</span>
<span class="amount-value">{{ (purchase && purchase.purchaseCount ? purchase.purchaseCount : 0).toFixed(2) }}</span>
</div> </div>
</el-card> </el-card>
<!-- 采购/领料 --> <!-- 采购/领料 -->
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> <el-table v-loading="loading" :data="expandedList" :stripe="true" :show-overflow-tooltip="true" :row-key="row => row._rowKey" :span-method="mergeCells">
<el-table-column label="序号" align="center"> <el-table-column label="序号" align="center" width="55" prop="_index">
<template scope="scope"> <template scope="scope">
<span>{{ scope.$index + 1 }}</span> <span>{{ scope.row._index + 1 }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="单号" align="center" prop="soNo" width="200"/> <el-table-column label="单号" align="center" prop="soNo" width="200"/>
<el-table-column label="车牌号" align="center" prop="licenseNumber" width="200"/> <el-table-column label="车牌号" align="center" prop="licenseNumber" width="200">
<template slot-scope="scope">
{{ scope.row.licenseNumber || '-' }}
</template>
</el-table-column>
<el-table-column label="数量" align="center" prop="itemCount" width="150"/> <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="totalPrice" width="150"/>
<el-table-column :label="soByType ? '采购员' : !isBack ? '领料人' : '退料人'" align="center" prop="userName" <el-table-column :label="soByType ? '采购员' : !isBack ? '领料人' : '退料人'" align="center" prop="userName"
@ -110,22 +118,48 @@
<dict-tag :type="DICT_TYPE.REPAIR_SO_STATUS" :value="scope.row.soStatus"/> <dict-tag :type="DICT_TYPE.REPAIR_SO_STATUS" :value="scope.row.soStatus"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="备注" align="center" prop="remark" width="180"/> <el-table-column label="备注" align="center" prop="remark" width="180">
<template slot-scope="scope">
{{ scope.row.remark || '-' }}
</template>
</el-table-column>
<el-table-column label="商品" align="center" prop="itemGoodsName" width="180">
<template slot-scope="scope">
{{ scope.row.itemGoodsName || '-' }}
</template>
</el-table-column>
<el-table-column label="商品数量" align="center" prop="itemGoodsCount" width="150">
<template slot-scope="scope">
{{ scope.row.itemGoodsCount || '-' }}
</template>
</el-table-column>
<el-table-column label="商品价格" align="center" prop="itemGoodsPrice" width="150">
<template slot-scope="scope">
{{ scope.row.itemGoodsPrice || '-' }}
</template>
</el-table-column>
<el-table-column label="仓库" align="center" prop="houseName" width="180">
<template slot-scope="scope">
{{ scope.row.houseName || '-' }}
</template>
</el-table-column>
<el-table-column label="操作" fixed="right" width="180" align="center"> <el-table-column label="操作" fixed="right" width="180" align="center">
<template v-slot="scope"> <template v-slot="scope">
<el-button size="mini" type="text" icon="el-icon-view" @click="handleShow(scope.row)" <template v-if="scope.row._isFirstItem">
>查看 <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-view" @click="handleShowIn(scope.row)" </el-button>
>查看入库单 <el-button size="mini" type="text" icon="el-icon-view" @click="handleShowIn(scope.row)"
</el-button> >查看入库单
<el-button @click="handleInWares(scope.row)" v-if="scope.row.soStatus === '02'" size="mini" type="text" </el-button>
icon="el-icon-edit-outline" <el-button @click="handleInWares(scope.row)" v-if="scope.row.soStatus === '02'" size="mini" type="text"
>入库 icon="el-icon-edit-outline"
</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-close" @click="handleVoidSo(scope.row)"
</el-button> >作废
</el-button>
</template>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -362,7 +396,10 @@ export default {
list: [], list: [],
loading: false, loading: false,
total: 0, total: 0,
purchaseAmount: 0, purchase: {
purchaseAmount: 0,
purchaseCount: 0
},
dialogVisible: false, dialogVisible: false,
inItems: [], inItems: [],
inItemsQuery: null, inItemsQuery: null,
@ -404,7 +441,12 @@ export default {
return row.id return row.id
}, },
inSoiList: [], inSoiList: [],
inLoading3: false inLoading3: false,
expandedList: [],
//
mergeProps: ['_index', 'soNo', 'itemCount', 'totalPrice', 'userName', 'supplierName', 'soTime', 'licenseNumber', 'createTime', 'corpName', 'soStatus', 'remark'],
//
itemProps: ['itemGoodsName', 'itemGoodsCount', 'itemGoodsPrice', 'houseName'],
} }
}, },
mounted() { mounted() {
@ -510,30 +552,145 @@ export default {
this.inItemsQuery = null this.inItemsQuery = null
this.searchByQuery() this.searchByQuery()
}, },
// items
processDataForMergeCells(data) {
const result = [];
let index = 0;
data.forEach((item, idx) => {
const items = item.items || [];
if (items.length > 0) {
items.forEach((subItem, subIdx) => {
const newItem = {
...item,
_index: idx, //
_rowKey: `${item.id}_${subIdx}`, //
_isFirstItem: subIdx === 0,
itemGoodsName: subItem.wares?.name || '-',
itemGoodsCount: subItem.goodsCount || '-',
itemGoodsPrice: subItem.goodsPrice || '-',
houseName: subItem.houseName || '-'
};
result.push(newItem);
});
} else {
// items
const newItem = {
...item,
_index: idx,
_rowKey: `${item.id}_0`,
_isFirstItem: true,
itemGoodsName: '-',
itemGoodsCount: '-',
itemGoodsPrice: '-',
houseName: '-'
};
result.push(newItem);
}
});
return result;
},
//
mergeCells({row, column, rowIndex, columnIndex}) {
//
if (this.itemProps.includes(column.property)) {
return { rowspan: 1, colspan: 1 };
}
//
if (column.property === undefined && column.label === '操作') {
if (row._isFirstItem) {
const mainId = row.id;
let count = 0;
// id
for (let i = rowIndex; i < this.expandedList.length; i++) {
if (this.expandedList[i].id === mainId) {
count++;
} else {
break;
}
}
return { rowspan: count, colspan: 1 };
} else {
return { rowspan: 0, colspan: 0 };
}
}
//
if (this.mergeProps.includes(column.property) || (column.property === undefined && column.label === '序号')) {
const mainId = row.id;
//
if (row._isFirstItem) {
let count = 0;
// id
for (let i = rowIndex; i < this.expandedList.length; i++) {
if (this.expandedList[i].id === mainId) {
count++;
} else {
break;
}
}
return { rowspan: count, colspan: 1 };
} else {
return { rowspan: 0, colspan: 0 };
}
}
return { rowspan: 1, colspan: 1 };
},
// //
async pageSo() { async pageSo() {
this.queryParams.soType = null this.queryParams.soType = null;
this.queryParams.purchaseType = null this.queryParams.purchaseType = null;
if (this.soByType && this.goodsYes) { if (this.soByType && this.goodsYes) {
this.queryParams.soType = "03" this.queryParams.soType = "03";
this.queryParams.purchaseType = "02" this.queryParams.purchaseType = "02";
} else if (this.soByType && !this.goodsYes) { } else if (this.soByType && !this.goodsYes) {
this.queryParams.soType = "01" this.queryParams.soType = "01";
this.queryParams.purchaseType = "01" this.queryParams.purchaseType = "01";
} else if (!this.soByType && !this.isBack) { } else if (!this.soByType && !this.isBack) {
this.queryParams.soType = "02" this.queryParams.soType = "02";
} else if (this.isBack) { } else if (this.isBack) {
this.queryParams.soType = '04' this.queryParams.soType = '04';
} }
try { try {
this.loading = true this.loading = true;
const res = await getRepairSoPage(this.queryParams) const res = await getRepairSoPage(this.queryParams);
this.list = res.data.records this.list = res.data.records;
this.total = res.data.total this.total = res.data.total;
const purchaseRes = await purchase(this.queryParams) // items
this.purchaseAmount = purchaseRes.data this.expandedList = this.processDataForMergeCells(this.list);
const purchaseRes = await purchase(this.queryParams);
// purchase
if (purchaseRes && purchaseRes.data) {
this.purchase = {
purchaseAmount: purchaseRes.data.purchaseAmount || 0,
purchaseCount: purchaseRes.data.purchaseCount || 0
};
} else {
this.purchase = {
purchaseAmount: 0,
purchaseCount: 0
};
}
} catch (error) {
//
console.error('获取采购数据失败:', error);
this.purchase = {
purchaseAmount: 0,
purchaseCount: 0
};
} finally { } finally {
this.loading = false this.loading = false;
} }
}, },
// //
@ -796,9 +953,12 @@ export default {
.amount-card { .amount-card {
margin-bottom: 20px; margin-bottom: 20px;
display: flex;
flex-wrap: wrap;
.amount-info { .amount-info {
display: flex; display: flex;
align-items: center; align-items: center;
margin-right: 30px;
.amount-label { .amount-label {
font-size: 14px; font-size: 14px;
color: #606266; color: #606266;

View File

@ -35,6 +35,17 @@
<right-toolbar :showSearch.sync="showSearch"></right-toolbar> <right-toolbar :showSearch.sync="showSearch"></right-toolbar>
</el-row> </el-row>
<!-- 采购金额展示 -->
<el-card class="amount-card">
<div class="amount-info">
<span class="amount-label">退货总金额</span>
<span class="amount-value">¥{{ (purchase && purchase.purchaseAmount ? purchase.purchaseAmount : 0).toFixed(2) }}</span>
</div>
<div class="amount-info">
<span class="amount-label">退货数量</span>
<span class="amount-value">{{ (purchase && purchase.purchaseCount ? purchase.purchaseCount : 0).toFixed(2) }}</span>
</div>
</el-card>
<!-- 表格 --> <!-- 表格 -->
<el-table v-loading="loading" :data="expandedList" :stripe="true" :show-overflow-tooltip="true" :row-key="row => row._rowKey" :span-method="mergeCells"> <el-table v-loading="loading" :data="expandedList" :stripe="true" :show-overflow-tooltip="true" :row-key="row => row._rowKey" :span-method="mergeCells">
<el-table-column label="序号" align="center" width="55" prop="_index"> <el-table-column label="序号" align="center" width="55" prop="_index">
@ -43,8 +54,8 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="单号" align="center" prop="soNo" width="200"/> <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="itemCount" width="150"/>
<el-table-column label="金额" align="center" prop="totalPrice" 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="supplierName"/>
<el-table-column label="退货时间" align="center" prop="soTime" <el-table-column label="退货时间" align="center" prop="soTime"
width="150"/> width="150"/>
@ -181,7 +192,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="供应商" align="center" prop="supplierName" width="180"> <el-table-column label="供应商" align="center" prop="supplierName" width="180">
<template slot-scope="scope"> <template >
{{info.supplierName}} {{info.supplierName}}
</template> </template>
</el-table-column> </el-table-column>
@ -205,7 +216,7 @@ import SupplierChoose from "@/views/repair/Components/SupplierChoose.vue";
import StaffChoose from "@/views/repair/Components/StaffChoose.vue"; import StaffChoose from "@/views/repair/Components/StaffChoose.vue";
import CorpChoose from "@/views/repair/Components/CorpChoose.vue"; import CorpChoose from "@/views/repair/Components/CorpChoose.vue";
import SoReturnForm from "@/views/repair/stockOperate/form/SoReturnForm.vue"; import SoReturnForm from "@/views/repair/stockOperate/form/SoReturnForm.vue";
import {getRepairSoById, getRepairSoPage, voidSo, exportData, getRepairSoPageItems} from "@/api/repair/stockOperate/stockOperate"; import {getRepairSoById, getRepairSoPage, voidSo, exportData, getRepairSoPageItems, purchase} from "@/api/repair/stockOperate/stockOperate";
import {getRepairSoiByIds} from "@/api/repair/stockOperate/stockOperateItem"; import {getRepairSoiByIds} from "@/api/repair/stockOperate/stockOperateItem";
import {getBaseWarehouseList} from "@/api/base/warehouse"; import {getBaseWarehouseList} from "@/api/base/warehouse";
@ -225,6 +236,7 @@ export default {
list: [], list: [],
expandedList: [], expandedList: [],
total: 0, total: 0,
purchase: {},
loading: false, loading: false,
supplier: null, supplier: null,
formData: { formData: {
@ -393,6 +405,19 @@ export default {
this.total = res.data.total this.total = res.data.total
// items // items
this.expandedList = this.processDataForMergeCells(this.list) this.expandedList = this.processDataForMergeCells(this.list)
const purchaseRes = await purchase(this.queryParams);
// purchase
if (purchaseRes && purchaseRes.data) {
this.purchase = {
purchaseAmount: purchaseRes.data.purchaseAmount || 0,
purchaseCount: purchaseRes.data.purchaseCount || 0
};
} else {
this.purchase = {
purchaseAmount: 0,
purchaseCount: 0
};
}
}finally { }finally {
this.loading = false this.loading = false
} }
@ -438,4 +463,24 @@ export default {
.box-card { .box-card {
margin-bottom: 10px; margin-bottom: 10px;
} }
.amount-card {
margin-bottom: 20px;
display: flex;
flex-wrap: wrap;
.amount-info {
display: flex;
align-items: center;
margin-right: 30px;
.amount-label {
font-size: 14px;
color: #606266;
margin-right: 8px;
}
.amount-value {
font-size: 18px;
font-weight: bold;
color: #f56c6c;
}
}
}
</style> </style>