diff --git a/src/views/hard/hard-order/components/admin-refund-dialog/index.vue b/src/views/hard/hard-order/components/admin-refund-dialog/index.vue index bb0b42b..50d868e 100644 --- a/src/views/hard/hard-order/components/admin-refund-dialog/index.vue +++ b/src/views/hard/hard-order/components/admin-refund-dialog/index.vue @@ -1,5 +1,5 @@ - + diff --git a/src/views/hard/hard-order/components/admin-refund-dialog/table.vue b/src/views/hard/hard-order/components/admin-refund-dialog/table.vue index e9cec80..2de3778 100644 --- a/src/views/hard/hard-order/components/admin-refund-dialog/table.vue +++ b/src/views/hard/hard-order/components/admin-refund-dialog/table.vue @@ -161,43 +161,47 @@ const { getDataList, sortChangeHandle, tableStyle } = useTable(state) const getCarList = async (orderId: string) => { state.queryForm.orderId = orderId - // 获取订单商品列表 - await getDataList() - if (!state.dataList || !state.dataList.length) { - return - } - // 获取已退款的商品 - const { data } = await hardCar.refundCar({ orderId }) - if (!data || !data.length) { - disposeDataList.value = state.dataList.map((item) => { + try { + // 获取订单商品列表 + await getDataList() + if (!state.dataList || !state.dataList.length) { + return + } + // 获取已退款的商品 + const { data } = await hardCar.refundCar({ orderId }) + if (!data || !data.length) { + disposeDataList.value = state.dataList.map((item) => { + if (!item) return null + return { + ...item, + refundProductCount: 0, + maxRefundProductCount: item.productCount, + refundProductWeight: 0, + maxRefundProductWeight: displayWeight(item.productWeight), + refundTotalPrice: 0, + } + }).filter(Boolean) + return + } + refundSuccessList.value = data + // 计算出需要退款的商品 + const refundViewList = [...state.dataList] + disposeDataList.value = refundViewList.map((item) => { if (!item) return null + const target = data.find((v: any) => v.productId == item.productId) return { ...item, refundProductCount: 0, - maxRefundProductCount: item.productCount, + maxRefundProductCount: item.productCount - (target?.productCount ?? 0), refundProductWeight: 0, - maxRefundProductWeight: displayWeight(item.productWeight), + maxRefundProductWeight: displayWeight(item.productWeight - (target?.productWeight ?? 0)), refundTotalPrice: 0, } }).filter(Boolean) - return + } catch (error: any) { + state.dataList = [] + disposeDataList.value = [] } - refundSuccessList.value = data - // 计算出需要退款的商品 - const refundViewList = [...state.dataList] - disposeDataList.value = refundViewList.map((item) => { - if (!item) return null - const target = data.find((v: any) => v.productId == item.productId) - return { - ...item, - refundProductCount: 0, - maxRefundProductCount: item.productCount - (target?.productCount ?? 0), - refundProductWeight: 0, - maxRefundProductWeight: displayWeight(item.productWeight - (target?.productWeight ?? 0)), - refundTotalPrice: 0, - } - }).filter(Boolean) - console.log("disposeDataList:", disposeDataList.value); } @@ -220,8 +224,6 @@ const handleAllRefund = () => { v.refundTotalPrice = target.totalPrice } - console.log("全部:", _list); - disposeDataList.value = _list } @@ -248,6 +250,11 @@ const getSummaries = (param: any) => { // 提交 const validate = async () => { + // 如果购物车为空直接返回true + if (!state.dataList || !state.dataList.length) { + return [] + } + let valid = false for (const v of disposeDataList.value) { if (v.refundProductCount > 0 || v.refundProductWeight > 0) { diff --git a/src/views/hard/hard-order/index.vue b/src/views/hard/hard-order/index.vue index 2c8e985..4ac90b9 100644 --- a/src/views/hard/hard-order/index.vue +++ b/src/views/hard/hard-order/index.vue @@ -80,7 +80,7 @@ - + @@ -229,7 +229,8 @@ v-auth="'hard_hardwareOrder_edit'" @click="formDialogRef.openDialog(row.id)"> 编辑 - 退款