更新
This commit is contained in:
parent
780f394407
commit
cf441fddf9
@ -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
|
||||||
})
|
})
|
||||||
|
|||||||
@ -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,9 +118,34 @@
|
|||||||
<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">
|
||||||
|
<template v-if="scope.row._isFirstItem">
|
||||||
<el-button size="mini" type="text" icon="el-icon-view" @click="handleShow(scope.row)"
|
<el-button size="mini" type="text" icon="el-icon-view" @click="handleShow(scope.row)"
|
||||||
>查看
|
>查看
|
||||||
</el-button>
|
</el-button>
|
||||||
@ -127,6 +160,7 @@
|
|||||||
>作废
|
>作废
|
||||||
</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,
|
||||||
|
purchase: {
|
||||||
purchaseAmount: 0,
|
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;
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user