|
@@ -549,6 +549,7 @@ export default {
|
|
|
this.GET_WarehouseEntry();
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
/** 获取出库单列表 */
|
|
|
GET_GoodsExchangeList() {
|
|
|
this.loading = true;
|
|
@@ -570,19 +571,37 @@ export default {
|
|
|
// 使用 Promise.all 处理所有异步请求
|
|
|
Promise.all(
|
|
|
response.data.map((el) => {
|
|
|
- return API_GoodsExchange.getGoodsExchangeInfo(el.id).then(
|
|
|
- (res) => {
|
|
|
- // 使用 map 获取所有商品名称,然后用逗号连接
|
|
|
- el.goodsName = res.product_list
|
|
|
- .map((e) => e.product_vo.name)
|
|
|
- .join(", ");
|
|
|
+ return API_GoodsExchange.getGoodsExchangeInfo(el.id)
|
|
|
+ .then((res) => {
|
|
|
+ try {
|
|
|
+ // 使用 map 获取所有商品名称,然后用逗号连接
|
|
|
+ if (res && res.product_list && Array.isArray(res.product_list)) {
|
|
|
+ el.goodsName = res.product_list
|
|
|
+ .map((e) => (e && e.product_vo ? e.product_vo.name : '未知商品'))
|
|
|
+ .join(", ");
|
|
|
+ } else {
|
|
|
+ el.goodsName = '无商品信息';
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('处理商品名称时出错:', error);
|
|
|
+ el.goodsName = '获取商品信息失败';
|
|
|
+ }
|
|
|
return el;
|
|
|
- }
|
|
|
- );
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ console.error(`获取ID为${el.id}的商品信息失败:`, error);
|
|
|
+ el.goodsName = '获取商品信息失败';
|
|
|
+ return el; // 即使请求失败也返回原始元素
|
|
|
+ });
|
|
|
})
|
|
|
- ).then(() => {
|
|
|
+ )
|
|
|
+ .then((results) => {
|
|
|
console.log(response);
|
|
|
this.tableData = response;
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ console.error('处理商品列表时出错:', error);
|
|
|
+ this.tableData = response; // 确保即使出错也能显示基本数据
|
|
|
});
|
|
|
})
|
|
|
.catch(() => {
|