|
|
@ -49,9 +49,9 @@ |
|
|
</view> |
|
|
</view> |
|
|
<!-- 选择理由模块 --> |
|
|
<!-- 选择理由模块 --> |
|
|
<view v-if="inspectData && inspectData.list"> |
|
|
<view v-if="inspectData && inspectData.list"> |
|
|
<view v-for="item in (inspectData.list.find(i => i.id === 'quality_issue')?.commonOrderList || [])" |
|
|
|
|
|
|
|
|
<view v-for="(item, index) in (inspectData.list.find(i => i.id === 'quality_issue')?.commonOrderList || [])" |
|
|
:key="item.id || item.testingStatus" class="row-reason"> |
|
|
:key="item.id || item.testingStatus" class="row-reason"> |
|
|
<text class="reason-label">质量问题</text> |
|
|
|
|
|
|
|
|
<text class="reason-label">质量问题{{ index + 1 }}</text> |
|
|
<view class="reason-select" @tap="selectReason(item)"> |
|
|
<view class="reason-select" @tap="selectReason(item)"> |
|
|
<text class="reason-placeholder" :class="{ 'selected': hasSelectedReason(item) }"> |
|
|
<text class="reason-placeholder" :class="{ 'selected': hasSelectedReason(item) }"> |
|
|
{{ hasSelectedReason(item) ? '已选择' : '请选择理由' }} |
|
|
{{ hasSelectedReason(item) ? '已选择' : '请选择理由' }} |
|
|
@ -65,7 +65,7 @@ |
|
|
<!-- 不可回收产品卡片 --> |
|
|
<!-- 不可回收产品卡片 --> |
|
|
<view v-if="hasUnrecyclableItems" class="result-card"> |
|
|
<view v-if="hasUnrecyclableItems" class="result-card"> |
|
|
<view class="card-title">不可回收产品</view> |
|
|
<view class="card-title">不可回收产品</view> |
|
|
<view v-for="item in unrecyclableList" :key="item.id" class="result-row"> |
|
|
|
|
|
|
|
|
<view v-for="item in unrecyclableList" :key="item.id" class="result-group"> |
|
|
<view class="row-main"> |
|
|
<view class="row-main"> |
|
|
<view class="goods-name-section"> |
|
|
<view class="goods-name-section"> |
|
|
<text class="goods-name">不可回收</text> |
|
|
<text class="goods-name">不可回收</text> |
|
|
@ -74,13 +74,17 @@ |
|
|
<text class="row-count">x{{ item.count }}</text> |
|
|
<text class="row-count">x{{ item.count }}</text> |
|
|
<text class="row-total">¥{{ item.total }}</text> |
|
|
<text class="row-total">¥{{ item.total }}</text> |
|
|
</view> |
|
|
</view> |
|
|
<view class="row-reason"> |
|
|
|
|
|
<text class="reason-label">不可回收</text> |
|
|
|
|
|
<view class="reason-select" @tap="selectReasonForUnrecyclable(item)"> |
|
|
|
|
|
<text class="reason-placeholder" :class="{ 'selected': hasSelectedReason(item) }"> |
|
|
|
|
|
{{ hasSelectedReason(item) ? '已选择' : '请选择理由' }} |
|
|
|
|
|
</text> |
|
|
|
|
|
<uni-icons type="right" size="18" color="#bbb" /> |
|
|
|
|
|
|
|
|
<!-- 选择理由模块 --> |
|
|
|
|
|
<view v-if="inspectData && inspectData.list"> |
|
|
|
|
|
<view v-for="(commonItem,index) in (inspectData.list.find(i => i.id === 'unrecyclable')?.commonOrderList || [])" |
|
|
|
|
|
:key="commonItem.id || commonItem.testingStatus" class="row-reason"> |
|
|
|
|
|
<text class="reason-label">不可回收{{ index +1 }}</text> |
|
|
|
|
|
<view class="reason-select" @tap="selectReason(commonItem)"> |
|
|
|
|
|
<text class="reason-placeholder" :class="{ 'selected': hasSelectedReason(commonItem) }"> |
|
|
|
|
|
{{ hasSelectedReason(commonItem) ? '已选择' : '请选择理由' }} |
|
|
|
|
|
</text> |
|
|
|
|
|
<uni-icons type="right" size="18" color="#bbb" /> |
|
|
|
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
@ -297,15 +301,16 @@ export default { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// 推荐方案一 |
|
|
|
|
|
// console.log('this.inspectData["list"]', this.inspectData["list"]) |
|
|
|
|
|
// 推荐方案一 |
|
|
|
|
|
// this.inspectData["list"].forEach(item => { |
|
|
|
|
|
// console.log('item1', item) |
|
|
|
|
|
// // delete item['categoryId'] |
|
|
|
|
|
// }) |
|
|
|
|
|
// 其余逻辑不变 |
|
|
|
|
|
const inspectDatas = {...this.inspectData,list:JSON.stringify(this.inspectData["list"], null, 2)} |
|
|
|
|
|
|
|
|
// 在提交前将质量问题和不可回收中的id值置为空 |
|
|
|
|
|
const processedList = this.inspectData["list"].map(item => { |
|
|
|
|
|
if (item.id === 'quality_issue' || item.id === 'unrecyclable') { |
|
|
|
|
|
// 对于质量问题和不可回收,将id置为空 |
|
|
|
|
|
return { ...item, id: '' } |
|
|
|
|
|
} |
|
|
|
|
|
return item |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const inspectDatas = {...this.inspectData, list: JSON.stringify(processedList, null, 2)} |
|
|
console.log('最终的质检数据:', inspectDatas); |
|
|
console.log('最终的质检数据:', inspectDatas); |
|
|
this.$api('submitQualityInfo', inspectDatas , res => { |
|
|
this.$api('submitQualityInfo', inspectDatas , res => { |
|
|
if (res && res.code === 200) { |
|
|
if (res && res.code === 200) { |
|
|
@ -316,19 +321,17 @@ export default { |
|
|
uni.showToast({ title: '完成质检', icon: 'success' }) |
|
|
uni.showToast({ title: '完成质检', icon: 'success' }) |
|
|
}, |
|
|
}, |
|
|
selectReason(item) { |
|
|
selectReason(item) { |
|
|
// 始终用inspectData.list中的最新对象 |
|
|
|
|
|
|
|
|
// 直接使用传入的item,因为它已经是commonOrderList中的具体项 |
|
|
let popupItem = item |
|
|
let popupItem = item |
|
|
|
|
|
let type = 0 // 默认类型 |
|
|
|
|
|
|
|
|
|
|
|
// 根据testingStatus确定类型 |
|
|
if (item.testingStatus === 1) { |
|
|
if (item.testingStatus === 1) { |
|
|
const qualityItem = this.inspectData["list"].find(i => i.id === 'quality_issue') |
|
|
|
|
|
if (qualityItem && qualityItem.commonOrderList) { |
|
|
|
|
|
popupItem = qualityItem.commonOrderList.find(i => i.id === item.id) || item |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
type = 1 // 质量问题 |
|
|
} else if (item.testingStatus === 2) { |
|
|
} else if (item.testingStatus === 2) { |
|
|
const unrecyclableItem = this.inspectData["list"].find(i => i.id === 'unrecyclable') |
|
|
|
|
|
if (unrecyclableItem && unrecyclableItem.commonOrderList) { |
|
|
|
|
|
popupItem = unrecyclableItem.commonOrderList.find(i => i.id === item.id) || item |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
type = 2 // 不可回收 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.currentReasonItem = popupItem |
|
|
this.currentReasonItem = popupItem |
|
|
// 判断类型,动态设置标题 |
|
|
// 判断类型,动态设置标题 |
|
|
if (popupItem.testingStatus === 1) { |
|
|
if (popupItem.testingStatus === 1) { |
|
|
@ -338,38 +341,55 @@ export default { |
|
|
} else { |
|
|
} else { |
|
|
this.currentReasonTitle = this.getGoodsName(popupItem.shopId || popupItem.id) |
|
|
this.currentReasonTitle = this.getGoodsName(popupItem.shopId || popupItem.id) |
|
|
} |
|
|
} |
|
|
this.reasonImages = popupItem.images || [] |
|
|
|
|
|
|
|
|
// 只使用testingImages字段 |
|
|
|
|
|
if (popupItem.testingImages && popupItem.testingImages.trim() !== '') { |
|
|
|
|
|
this.reasonImages = popupItem.testingImages.split(',').filter(img => img.trim() !== '') |
|
|
|
|
|
} else { |
|
|
|
|
|
this.reasonImages = [] |
|
|
|
|
|
} |
|
|
// 不在这里设置reasonChecked |
|
|
// 不在这里设置reasonChecked |
|
|
this.selectReasonForUnqualified(popupItem, 0) |
|
|
|
|
|
|
|
|
this.selectReasonForUnqualified(popupItem, type) |
|
|
this.lockScroll() |
|
|
this.lockScroll() |
|
|
this.$refs.reasonPopup.open() |
|
|
this.$refs.reasonPopup.open() |
|
|
}, |
|
|
}, |
|
|
selectReasonForQualified(item) { |
|
|
selectReasonForQualified(item) { |
|
|
this.currentReasonItem = item |
|
|
this.currentReasonItem = item |
|
|
this.currentReasonTitle = this.getGoodsName(item.shopId || item.id) |
|
|
this.currentReasonTitle = this.getGoodsName(item.shopId || item.id) |
|
|
this.reasonImages = item.images || [] |
|
|
|
|
|
|
|
|
// 只使用testingImages字段 |
|
|
|
|
|
if (item.testingImages && item.testingImages.trim() !== '') { |
|
|
|
|
|
this.reasonImages = item.testingImages.split(',').filter(img => img.trim() !== '') |
|
|
|
|
|
} else { |
|
|
|
|
|
this.reasonImages = [] |
|
|
|
|
|
} |
|
|
// 不在这里设置reasonChecked |
|
|
// 不在这里设置reasonChecked |
|
|
this.selectReasonForUnqualified(item, 1) |
|
|
this.selectReasonForUnqualified(item, 1) |
|
|
this.lockScroll() |
|
|
this.lockScroll() |
|
|
this.$refs.reasonPopup.open() |
|
|
this.$refs.reasonPopup.open() |
|
|
}, |
|
|
}, |
|
|
selectReasonForUnrecyclable(item) { |
|
|
|
|
|
this.currentReasonItem = item |
|
|
|
|
|
this.currentReasonTitle = '不可回收' |
|
|
|
|
|
this.reasonImages = item.images || [] |
|
|
|
|
|
// 不在这里设置reasonChecked |
|
|
|
|
|
this.selectReasonForUnqualified(item, 2) |
|
|
|
|
|
this.lockScroll() |
|
|
|
|
|
this.$refs.reasonPopup.open() |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
selectReasonForUnqualified(item, type) { |
|
|
selectReasonForUnqualified(item, type) { |
|
|
|
|
|
// 根据类型确定classId |
|
|
|
|
|
let classId = '' |
|
|
|
|
|
if (type === 1) { |
|
|
|
|
|
// 质量问题 |
|
|
|
|
|
classId = 'quality_issue' |
|
|
|
|
|
} else if (type === 2) { |
|
|
|
|
|
// 不可回收 |
|
|
|
|
|
classId = 'unrecyclable' |
|
|
|
|
|
} else { |
|
|
|
|
|
// 普通商品,使用shopClass |
|
|
|
|
|
classId = item.shopClass || '' |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
console.log('[selectReasonForUnqualified] classId:', classId, 'type:', type) |
|
|
|
|
|
|
|
|
this.$api('getcheckoutReasons', { |
|
|
this.$api('getcheckoutReasons', { |
|
|
classId: item.shopClass, |
|
|
|
|
|
|
|
|
classId: classId, |
|
|
type: type |
|
|
type: type |
|
|
}, res => { |
|
|
}, res => { |
|
|
if (res.code == 200) { |
|
|
if (res.code == 200) { |
|
|
this.reasonOptions = res.result; |
|
|
this.reasonOptions = res.result; |
|
|
if (item.testingInstructions) { |
|
|
|
|
|
|
|
|
if (item.testingInstructions && item.testingInstructions.trim() !== '') { |
|
|
this.reasonChecked = item.testingInstructions.split(',').map(s => s.trim()).filter(Boolean) |
|
|
this.reasonChecked = item.testingInstructions.split(',').map(s => s.trim()).filter(Boolean) |
|
|
} else { |
|
|
} else { |
|
|
this.reasonChecked = [] |
|
|
this.reasonChecked = [] |
|
|
@ -379,7 +399,19 @@ export default { |
|
|
console.log('[selectReasonForUnqualified] reasonOptions:', this.reasonOptions) |
|
|
console.log('[selectReasonForUnqualified] reasonOptions:', this.reasonOptions) |
|
|
console.log('[selectReasonForUnqualified] reasonChecked:', this.reasonChecked) |
|
|
console.log('[selectReasonForUnqualified] reasonChecked:', this.reasonChecked) |
|
|
}) |
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
console.error('[selectReasonForUnqualified] API返回错误:', res) |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: '获取理由列表失败', |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
}, err => { |
|
|
|
|
|
console.error('[selectReasonForUnqualified] API调用失败:', err) |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: '获取理由列表失败', |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
closeReasonPopup() { |
|
|
closeReasonPopup() { |
|
|
@ -469,88 +501,14 @@ export default { |
|
|
saveReason() { |
|
|
saveReason() { |
|
|
if (this.currentReasonItem) { |
|
|
if (this.currentReasonItem) { |
|
|
console.log('this.currentReasonItem', this.currentReasonItem) |
|
|
console.log('this.currentReasonItem', this.currentReasonItem) |
|
|
this.currentReasonItem.images = [...this.reasonImages] |
|
|
|
|
|
|
|
|
// 直接更新当前项 |
|
|
this.currentReasonItem.testingInstructions = this.reasonChecked.join(',') |
|
|
this.currentReasonItem.testingInstructions = this.reasonChecked.join(',') |
|
|
this.updateInspectData() |
|
|
|
|
|
|
|
|
this.currentReasonItem.testingImages = this.reasonImages.join(',') |
|
|
} |
|
|
} |
|
|
this.closeReasonPopup() |
|
|
this.closeReasonPopup() |
|
|
}, |
|
|
}, |
|
|
updateInspectData() { |
|
|
|
|
|
if (!this.inspectData || !this.currentReasonItem) return |
|
|
|
|
|
// 获取选中的理由ID(假设理由选项的索引就是ID) |
|
|
|
|
|
const selectedReasonIds = [] |
|
|
|
|
|
this.reasonChecked.forEach((checked, index) => { |
|
|
|
|
|
if (checked) { |
|
|
|
|
|
selectedReasonIds.push(this.reasonOptions[index].reason.toString()) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
// 将理由ID用逗号分割保存 |
|
|
|
|
|
const testingInstructions = selectedReasonIds.join(',') |
|
|
|
|
|
// 将图片URL用逗号分割保存 |
|
|
|
|
|
const testingImages = this.reasonImages.join(',') |
|
|
|
|
|
// 根据当前选择的商品类型,找到对应的inspectData项进行更新 |
|
|
|
|
|
if (this.isQualifiedItem(this.currentReasonItem)) { |
|
|
|
|
|
this.updateQualifiedItemInspectData(testingInstructions, testingImages) |
|
|
|
|
|
} else if (this.isUnqualifiedItem(this.currentReasonItem)) { |
|
|
|
|
|
this.updateUnqualifiedItemInspectData(testingInstructions, testingImages) |
|
|
|
|
|
} else if (this.isUnrecyclableItem(this.currentReasonItem)) { |
|
|
|
|
|
this.updateUnrecyclableItemInspectData(testingInstructions, testingImages) |
|
|
|
|
|
} |
|
|
|
|
|
console.log('[updateInspectData] after update', JSON.stringify(this.inspectData, null, 2)) |
|
|
|
|
|
}, |
|
|
|
|
|
isQualifiedItem(item) { |
|
|
|
|
|
return this.qualifiedList.some(qualified => qualified.shopId === item.shopId) |
|
|
|
|
|
}, |
|
|
|
|
|
isUnqualifiedItem(item) { |
|
|
|
|
|
return this.unqualifiedGroups.some(group => |
|
|
|
|
|
group.items.some(unqualified => unqualified.id === item.id) |
|
|
|
|
|
) |
|
|
|
|
|
}, |
|
|
|
|
|
isUnrecyclableItem(item) { |
|
|
|
|
|
return this.unrecyclableList.some(unrecyclable => unrecyclable.id === item.id) |
|
|
|
|
|
}, |
|
|
|
|
|
updateQualifiedItemInspectData(testingInstructions, testingImages) { |
|
|
|
|
|
const inspectItem = this.inspectData["list"].find(item => item.id == this.currentReasonItem.id) |
|
|
|
|
|
if (inspectItem && inspectItem.commonOrderList) { |
|
|
|
|
|
// 为合格的商品更新所有状态为0的项 |
|
|
|
|
|
inspectItem.commonOrderList.forEach(commonItem => { |
|
|
|
|
|
if (commonItem.testingStatus === 0) { |
|
|
|
|
|
commonItem.testingInstructions = testingInstructions |
|
|
|
|
|
commonItem.testingImages = testingImages |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
updateUnqualifiedItemInspectData(testingInstructions, testingImages) { |
|
|
|
|
|
// 对于不合格商品,需要根据具体的commonOrderList项ID来更新 |
|
|
|
|
|
this.unqualifiedGroups.forEach(group => { |
|
|
|
|
|
const targetItem = group.items.find(item => item.id === this.currentReasonItem.id) |
|
|
|
|
|
if (targetItem) { |
|
|
|
|
|
// 找到对应的inspectData项 |
|
|
|
|
|
const inspectItem = this.inspectData["list"].find(item => item.id == group.id) |
|
|
|
|
|
if (inspectItem && inspectItem.commonOrderList) { |
|
|
|
|
|
// 根据不合格项的ID找到对应的commonOrderList项 |
|
|
|
|
|
const commonItem = inspectItem.commonOrderList.find(common => common.id === targetItem.id) |
|
|
|
|
|
if (commonItem) { |
|
|
|
|
|
commonItem.testingInstructions = testingInstructions |
|
|
|
|
|
commonItem.testingImages = testingImages |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
updateUnrecyclableItemInspectData(testingInstructions, testingImages) { |
|
|
|
|
|
const inspectItem = this.inspectData["list"].find(item => item.id == this.currentReasonItem.id) |
|
|
|
|
|
if (inspectItem && inspectItem.commonOrderList) { |
|
|
|
|
|
// 为不可回收的商品更新所有状态为2的项 |
|
|
|
|
|
inspectItem.commonOrderList.forEach(commonItem => { |
|
|
|
|
|
if (commonItem.testingStatus === 2) { |
|
|
|
|
|
commonItem.testingInstructions = testingInstructions |
|
|
|
|
|
commonItem.testingImages = testingImages |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lockScroll() { |
|
|
lockScroll() { |
|
|
// 禁用页面滚动 |
|
|
// 禁用页面滚动 |
|
|
this.isPopupOpen = true |
|
|
this.isPopupOpen = true |
|
|
@ -579,7 +537,8 @@ export default { |
|
|
hasSelectedReason(item) { |
|
|
hasSelectedReason(item) { |
|
|
// console.log('item', item) |
|
|
// console.log('item', item) |
|
|
// 检查该商品是否已选择理由或上传图片 |
|
|
// 检查该商品是否已选择理由或上传图片 |
|
|
return (item.images && item.images.length > 0) |
|
|
|
|
|
|
|
|
return (item.testingInstructions && item.testingInstructions.trim() !== '') || |
|
|
|
|
|
(item.testingImages && item.testingImages.trim() !== '') |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|