|
|
@ -41,6 +41,7 @@ |
|
|
|
<text class="goods-unit">/件</text> |
|
|
|
<text class="goods-count">x{{item.count}}</text> |
|
|
|
</view> |
|
|
|
<view class="goods-total">¥{{item.total}}</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
@ -63,45 +64,21 @@ |
|
|
|
<view class="goods-desc">{{item.desc}}</view> |
|
|
|
<view class="goods-bottom-row"> |
|
|
|
<view class="goods-price-row problem-price-row"> |
|
|
|
<text class="goods-price">¥{{item.price}}</text> |
|
|
|
<text class="goods-unit">/件</text> |
|
|
|
<!-- <text class="goods-price">¥{{item.price}}</text> |
|
|
|
<text class="goods-unit">/件</text> --> |
|
|
|
<text class="goods-count">x{{item.count}}</text> |
|
|
|
</view> |
|
|
|
<!-- <view class="goods-total">¥{{item.total}}</view> --> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="summary-row"> |
|
|
|
<text>件数:<text class="highlight">{{problemCount}}</text> 件</text> |
|
|
|
<text>结算金额:<text class="highlight">¥{{problemAmount}}</text></text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view v-if="showUnrecyclable && unrecyclableList.length" class="inspection-card problem-card"> |
|
|
|
<view class="report-title">不可回收</view> |
|
|
|
<view class="goods-list"> |
|
|
|
<view class="goods-item" v-for="(item, i) in unrecyclableList" :key="i"> |
|
|
|
<image class="goods-img" :src="item.img" mode="aspectFit" /> |
|
|
|
<view class="goods-info"> |
|
|
|
<view class="goods-row"> |
|
|
|
<view class="goods-name">{{item.name}}</view> |
|
|
|
</view> |
|
|
|
<view class="goods-desc">{{item.desc}}</view> |
|
|
|
<view class="goods-bottom-row"> |
|
|
|
<view class="goods-price-row"> |
|
|
|
<text class="goods-price">¥{{item.price}}</text> |
|
|
|
<text class="goods-unit">/件</text> |
|
|
|
<text class="goods-count">x{{item.count}}</text> |
|
|
|
</view> |
|
|
|
<view class="goods-total">¥0</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="summary-row"> |
|
|
|
<text>件数:<text class="highlight">{{unrecyclableCount}}</text> 件</text> |
|
|
|
<text>结算金额:<text class="highlight">¥0</text></text> |
|
|
|
<text>结算金额:<text class="highlight">¥ 0</text></text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</template> |
|
|
@ -119,11 +96,9 @@ export default { |
|
|
|
featureTags: ['透明检', '专业验', '公正评', '逐件验'], |
|
|
|
goodsList: [], // 质检合格 |
|
|
|
problemList: [], // 质量问题 |
|
|
|
unrecyclableList: [], // 不可回收 |
|
|
|
reportData: null, |
|
|
|
showQualified: false, |
|
|
|
showProblem: false, |
|
|
|
showUnrecyclable: false |
|
|
|
showProblem: false |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
@ -138,9 +113,6 @@ export default { |
|
|
|
}, |
|
|
|
problemAmount() { |
|
|
|
return this.problemList.reduce((sum, item) => sum + item.total, 0).toFixed(1) |
|
|
|
}, |
|
|
|
unrecyclableCount() { |
|
|
|
return this.unrecyclableList.reduce((sum, item) => sum + item.count, 0) |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad(options) { |
|
|
@ -148,53 +120,80 @@ export default { |
|
|
|
this.statusBarHeight = sysInfo.statusBarHeight |
|
|
|
this.navBarHeight = 14 |
|
|
|
this.navBarTotalHeight = this.statusBarHeight + this.navBarHeight |
|
|
|
// 获取 id 或 goodsId,优先 id |
|
|
|
const goodsId = options.id || options.goodsId |
|
|
|
if (goodsId) { |
|
|
|
this.fetchQualityReport(goodsId) |
|
|
|
// 获取 orderId |
|
|
|
const orderId = options.orderId |
|
|
|
if (orderId) { |
|
|
|
this.fetchQualityReport(orderId) |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
async fetchQualityReport(goodsId) { |
|
|
|
// 假设 this.$api 可用 |
|
|
|
this.$api && this.$api('getQualityReport', { goodsId }, res => { |
|
|
|
async fetchQualityReport(orderId) { |
|
|
|
// 调用订单详情接口 |
|
|
|
this.$api && this.$api('getOrderDetail', { orderId }, res => { |
|
|
|
if (res && res.code === 200 && res.result) { |
|
|
|
this.reportData = res.result |
|
|
|
// 适配数据 |
|
|
|
const status = Number(res.result.testingStatus) |
|
|
|
// 0: 质量问题,1: 质检合格,2: 不可回收 |
|
|
|
this.showQualified = status === 1 || status === 0 // 0和1都可能有合格 |
|
|
|
this.showProblem = status === 0 || status === 1 // 0和1都可能有问题 |
|
|
|
this.showUnrecyclable = status === 2 |
|
|
|
// 合格/问题都用同一条数据(如有多个需后端返回数组) |
|
|
|
if (status === 1) { |
|
|
|
this.goodsList = [this.mapReportToGoods(res.result)] |
|
|
|
this.problemList = [] |
|
|
|
this.unrecyclableList = [] |
|
|
|
} else if (status === 0) { |
|
|
|
this.goodsList = [] |
|
|
|
this.problemList = [this.mapReportToGoods(res.result, true)] |
|
|
|
this.unrecyclableList = [] |
|
|
|
} else if (status === 2) { |
|
|
|
this.goodsList = [] |
|
|
|
this.problemList = [] |
|
|
|
this.unrecyclableList = [this.mapReportToGoods(res.result)] |
|
|
|
} |
|
|
|
// 解析嵌套的订单数据 |
|
|
|
this.parseOrderData(res.result) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
mapReportToGoods(data, isProblem = false) { |
|
|
|
|
|
|
|
parseOrderData(orderData) { |
|
|
|
// 重置数据 |
|
|
|
this.goodsList = [] |
|
|
|
this.problemList = [] |
|
|
|
|
|
|
|
// 遍历主订单的 commonOrderList |
|
|
|
if (orderData.commonOrderList && orderData.commonOrderList.length > 0) { |
|
|
|
orderData.commonOrderList.forEach(mainOrder => { |
|
|
|
// 如果有子订单列表,遍历子订单 |
|
|
|
if (mainOrder.commonOrderList && mainOrder.commonOrderList.length > 0) { |
|
|
|
mainOrder.commonOrderList.forEach(subOrder => { |
|
|
|
this.categorizeOrderItem(subOrder, mainOrder) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// 如果没有子订单,直接处理主订单项 |
|
|
|
this.categorizeOrderItem(mainOrder) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
// 设置显示状态 |
|
|
|
this.showQualified = this.goodsList.length > 0 |
|
|
|
this.showProblem = this.problemList.length > 0 |
|
|
|
}, |
|
|
|
|
|
|
|
categorizeOrderItem(orderItem, parentOrder = null) { |
|
|
|
const status = Number(orderItem.testingStatus) |
|
|
|
const parentData = parentOrder || orderItem |
|
|
|
|
|
|
|
// 根据 testingStatus 分类:0-质检合格,1-质量问题 |
|
|
|
if (status === 0) { |
|
|
|
// 质检合格 |
|
|
|
this.goodsList.push(this.mapOrderToGoods(orderItem, parentData)) |
|
|
|
} else if (status === 1) { |
|
|
|
// 质量问题 |
|
|
|
this.problemList.push(this.mapOrderToGoods(orderItem, parentData, true)) |
|
|
|
} |
|
|
|
// 移除 testingStatus = 2 (不可回收) 的处理 |
|
|
|
}, |
|
|
|
|
|
|
|
mapOrderToGoods(orderItem, parentData, isProblem = false) { |
|
|
|
return { |
|
|
|
img: data.image, |
|
|
|
name: data.title || '未知品类', |
|
|
|
desc: data.details || '', |
|
|
|
price: data.onePrice || 0, |
|
|
|
count: data.num || 1, |
|
|
|
total: (data.onePrice || 0) * (data.num || 1), |
|
|
|
img: parentData.image || '/static/default-goods.png', |
|
|
|
name: parentData.title || '未知品类', |
|
|
|
desc: parentData.pinName ? `${parentData.pinName}` :'', |
|
|
|
price: parentData.onePrice || 0, |
|
|
|
count: orderItem.num || 1, |
|
|
|
total: parentData.price, |
|
|
|
detail: true, |
|
|
|
problemDesc: isProblem ? (data.testingInstructions || '') : '' |
|
|
|
testingInstructions: orderItem.testingInstructions || '', |
|
|
|
testingImages: orderItem.testingImages || '', |
|
|
|
testingTime: orderItem.testingTime || '', |
|
|
|
problemDesc: isProblem ? (orderItem.testingInstructions || '') : '' |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
async onRefresh() { |
|
|
|
// 模拟刷新数据 |
|
|
|
await new Promise(resolve => setTimeout(resolve, 1000)) |
|
|
@ -204,15 +203,22 @@ export default { |
|
|
|
uni.navigateBack() |
|
|
|
}, |
|
|
|
goToInspectionDetail(status) { |
|
|
|
// 取接口返回的字段 |
|
|
|
const d = this.reportData || {} |
|
|
|
uni.navigateTo({ |
|
|
|
url: `/pages/subcomponent/inspection-detail?status=${status}` + |
|
|
|
`&testingStatus=${d.testingStatus || ''}` + |
|
|
|
`&testingInstructions=${encodeURIComponent(d.testingInstructions || '')}` + |
|
|
|
`&testingTime=${encodeURIComponent(d.testingTime || '')}` + |
|
|
|
`&testingImages=${encodeURIComponent(d.testingImages || '')}` |
|
|
|
}) |
|
|
|
// 根据状态获取对应的商品数据 |
|
|
|
let itemData = null |
|
|
|
if (status === 'qualified' && this.goodsList.length > 0) { |
|
|
|
itemData = this.goodsList[0] |
|
|
|
} else if (status === 'problem' && this.problemList.length > 0) { |
|
|
|
itemData = this.problemList[0] |
|
|
|
} |
|
|
|
|
|
|
|
if (itemData) { |
|
|
|
uni.navigateTo({ |
|
|
|
url: `/pages/subcomponent/inspection-detail?status=${status}` + |
|
|
|
`&testingInstructions=${encodeURIComponent(itemData.testingInstructions || '')}` + |
|
|
|
`&testingTime=${encodeURIComponent(itemData.testingTime || '')}` + |
|
|
|
`&testingImages=${encodeURIComponent(itemData.testingImages || '')}` |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -359,7 +365,7 @@ export default { |
|
|
|
border-radius: 32rpx; |
|
|
|
box-shadow: 0 8rpx 32rpx rgba(60, 167, 250, 0.08); |
|
|
|
padding: 40rpx 32rpx 32rpx 32rpx; |
|
|
|
margin: -60rpx auto 0 auto; |
|
|
|
margin: 24rpx auto 0 auto; |
|
|
|
width: calc(100vw - 64rpx); |
|
|
|
max-width: 700rpx; |
|
|
|
display: flex; |
|
|
|