From 19db1c54ad7018c16aa476e0dcb9e33d912bc7f0 Mon Sep 17 00:00:00 2001 From: Lj <1095098147@qq.com> Date: Wed, 2 Jul 2025 15:38:22 +0800 Subject: [PATCH] =?UTF-8?q?'=E5=AE=8C=E5=96=84=E8=B4=A8=E6=A3=80=E5=8A=9F?= =?UTF-8?q?=E8=83=BD'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/model/index.js | 5 + config.js | 2 +- pages/component/home.vue | 10 +- pages/component/my.vue | 28 +- pages/component/recycle copy.vue | 4 +- pages/component/recycle.vue | 20 +- pages/manager/inspect-result.vue | 543 ++++++++++++++++--------------- pages/manager/inspect.vue | 372 ++++++++++----------- pages/manager/order-detail.vue | 12 +- pages/manager/order.vue | 4 +- pages/manager/user.vue | 18 +- pages/subcomponent/brand.vue | 2 +- pages/subcomponent/detail.vue | 8 +- pages/subcomponent/inspection-report.vue | 53 ++- pages/subcomponent/order.vue | 5 +- pages/subcomponent/order_edit.vue | 2 +- pages/subcomponent/pickup.vue | 4 +- pages/subcomponent/wallet.vue | 16 +- 18 files changed, 562 insertions(+), 546 deletions(-) diff --git a/api/model/index.js b/api/model/index.js index 9ebe757..38e8701 100644 --- a/api/model/index.js +++ b/api/model/index.js @@ -227,6 +227,11 @@ const api = { method: 'POST', auth: true, }, + getGoodsDetail: { + url: '/recycle-admin/applet/class/getGoodsDetail', + method: 'GET', + auth: true, + }, } export default api \ No newline at end of file diff --git a/config.js b/config.js index b78c2f0..2658c24 100644 --- a/config.js +++ b/config.js @@ -1,5 +1,5 @@ // config.js -const type = 'prod' +const type = 'dev' const config = { local: { diff --git a/pages/component/home.vue b/pages/component/home.vue index 7fc684a..0a239d7 100644 --- a/pages/component/home.vue +++ b/pages/component/home.vue @@ -38,12 +38,12 @@ @pause="onVideoPause(index)" @ended="onVideoEnded(index)" > - - - + + + - - + + diff --git a/pages/component/my.vue b/pages/component/my.vue index 3d59f49..787524d 100644 --- a/pages/component/my.vue +++ b/pages/component/my.vue @@ -85,11 +85,14 @@ - {{ order.num || 1 }} 件 - ¥{{ order.onePrice || 0 }} /件 + {{ order.num || 1 }} {{ order.unit }} + - - 预估 ¥ {{ order.price }} + + 结算 ¥ {{ order.price }} + + + 预估 ¥ {{ order.estimatedPrice }} @@ -365,23 +368,14 @@ export default { return item ? item.keyContent : '' }, userTypeText() { - // 根据 isTuiType 字段判断用户类型 - // 0: 用户,1:推广达人,2:推广大使 - switch (this.userInfo.isTuiType) { - case 1: - return '推广达人' - case 2: - return '推广大使' - default: - return '用户' - } + return this.userInfo.isTuiTypeTitle || '用户' }, userTypeBadgeClass() { // 根据用户类型返回不同的样式类 - switch (this.userInfo.isTuiType) { - case 1: + switch (this.userInfo.isTuiTypeTitle) { + case '推广达人': return 'avatar-badge-expert' // 推广达人 - case 2: + case '推广大使': return 'avatar-badge-ambassador' // 推广大使 default: return 'avatar-badge-user' // 普通用户 diff --git a/pages/component/recycle copy.vue b/pages/component/recycle copy.vue index b34939a..bf6ebf8 100644 --- a/pages/component/recycle copy.vue +++ b/pages/component/recycle copy.vue @@ -70,7 +70,7 @@ ¥ {{item.price}} - /件 + /{{item.unit}} @@ -138,7 +138,7 @@ {{item.name}} {{2222}} - ¥{{item.price}}/件 + ¥{{item.price}}/{{item.unit}} diff --git a/pages/component/recycle.vue b/pages/component/recycle.vue index 42304c3..8dd1521 100644 --- a/pages/component/recycle.vue +++ b/pages/component/recycle.vue @@ -22,28 +22,28 @@ @click="playVideoFullscreen(item, index)" /> - + > @@ -99,12 +99,12 @@ - - ¥ + + ¥ {{item.price}} {{item.price}}-{{item.maxPrice}} - /{{ item.unit || '件' }} - + /{{ item.unit || '件' }} + {{getItemTotalQuantity(item)}} diff --git a/pages/manager/inspect-result.vue b/pages/manager/inspect-result.vue index ae04dc2..8aceaf7 100644 --- a/pages/manager/inspect-result.vue +++ b/pages/manager/inspect-result.vue @@ -14,18 +14,18 @@ 合格产品 - + - {{getItemName(item.id)}} - {{getItemBrand(item.id)}} + {{ item.shopId ? getGoodsName(item.shopId) : (item.id === 'unrecyclable' ? '不可回收' + : (item.id === 'quality_issue' ? '质量问题' : ''))}} + {{ getItemBrand(item.shopId) }} - ¥ {{item.price}} /件 - x{{item.count}} - ¥{{item.total}} + x{{ item.count }} + ¥{{ item.total }} - {{getItemName(item.id)}} + {{ getGoodsName(item.shopId) }} {{ hasSelectedReason(item) ? '已选择' : '请选择理由(选填)' }} @@ -38,22 +38,26 @@ 不合格产品 - + - {{getItemName(group.id)}} - {{getItemBrand(group.id)}} + 质量问题 + - ¥ {{group.price}} /件 - ¥{{group.total}} + x{{ group.count }} + ¥{{ group.total }} - - {{item.name}} - - - {{ hasSelectedReason(item) ? '已选择' : '请选择理由' }} - - + + + + 质量问题 + + + {{ hasSelectedReason(item) ? '已选择' : '请选择理由' }} + + + @@ -64,18 +68,17 @@ - {{getItemName(item.id)}} - {{getItemBrand(item.id)}} + 不可回收 + - ¥ {{item.price || '—'}} /件 - x{{item.count}} - ¥{{item.total}} + x{{ item.count }} + ¥{{ item.total }} - {{getItemName(item.id)}} + 不可回收 - {{ hasSelectedReason(item) ? '已选择' : '请选择理由(选填)' }} + {{ hasSelectedReason(item) ? '已选择' : '请选择理由' }} @@ -126,7 +129,7 @@ - + {{ item.reason }} @@ -150,6 +153,7 @@ export default { qualifiedList: [], unqualifiedGroups: [], unrecyclableList: [], + goodsNameMap: {}, // 商品id => 名称 reasonPopupVisible: false, currentReasonTitle: '', reasonImages: [], @@ -170,155 +174,93 @@ export default { return this.unrecyclableList && this.unrecyclableList.length > 0 } }, - onLoad(options) { - // 接收质检数据和订单数据 - if (options && options.resultData) { - try { - const resultData = JSON.parse(decodeURIComponent(options.resultData)) - this.inspectData = resultData.inspectResult - this.order = resultData.order - console.log('接收到的质检数据:', this.inspectData) - console.log('接收到的订单数据:', this.order) - this.processInspectData() - } catch (error) { - console.error('解析数据失败:', error) - } + onLoad(options) { + // 接收质检数据和订单数据 + if (options && options.resultData) { + try { + const resultData = JSON.parse(decodeURIComponent(options.resultData)) + this.inspectData = resultData.inspectResult + this.order = resultData.order + this.processInspectData() + } catch (error) { + console.error('解析数据失败:', error) } - - // 兼容旧的参数格式 - if (options && options.inspectData && !options.resultData) { - try { - this.inspectData = JSON.parse(decodeURIComponent(options.inspectData)) - console.log('接收到的质检数据:', this.inspectData) - this.processInspectData() - } catch (error) { - console.error('解析质检数据失败:', error) - } + } + if (options && options.inspectData && !options.resultData) { + try { + this.inspectData = JSON.parse(decodeURIComponent(options.inspectData)) + this.processInspectData() + } catch (error) { + console.error('解析质检数据失败:', error) } - }, + } + }, methods: { - - processInspectData() { - if (!this.inspectData || !this.inspectData.list) return - + async processInspectData() { + if (!this.inspectData || !this.inspectData["list"]) return this.qualifiedList = [] this.unqualifiedGroups = [] this.unrecyclableList = [] - - this.inspectData.list.forEach(item => { - // 跳过不可回收分类 - if (item.id === 'unrecyclable') return - - // 从order中获取对应的商品信息 - const orderItem = this.order?.commonOrderList?.find(orderGoods => orderGoods.id == item.id) - if (!orderItem) return - - const itemName = orderItem.title || '未知商品' - const itemBrand = orderItem.pinName || '' - const displayName = itemBrand ? `${itemName} ${itemBrand}` : itemName - const itemNames = itemBrand ? `${itemName}` : itemName - const itemPrice = orderItem.onePrice || 0 - - // 统计各种状态的数量 - let qualifiedCount = 0 - let unqualifiedCount = 0 - let unrecyclableCount = 0 - - console.log('item', item) - item.commonOrderList.forEach(commonItem => { - if (commonItem.testingStatus === 0) { - qualifiedCount++ - } else if (commonItem.testingStatus === 1) { - unqualifiedCount++ - } else if (commonItem.testingStatus === 2) { - unrecyclableCount++ - } - }) - - // 处理合格产品 - if (qualifiedCount > 0) { - // 获取合格商品的理由和图片信息 - const qualifiedCommonItem = item.commonOrderList.find(commonItem => commonItem.testingStatus === 0) - const savedImages = qualifiedCommonItem?.testingImages ? qualifiedCommonItem.testingImages.split(',').filter(img => img) : [] - const savedReasons = this.parseTestingInstructions(qualifiedCommonItem?.testingInstructions || '') - + // 只收集普通商品的 shopId 作为 goodsId + const allIds = [] + this.inspectData["list"].forEach(item => { + if (item.shopId && item.id !== 'unrecyclable' && item.id !== 'quality_issue') { + allIds.push(item.shopId) + } + }) + console.log('allIds', allIds) + const uniqueIds = Array.from(new Set(allIds.filter(Boolean))) + console.log('uniqueIds', uniqueIds) + await this.fetchGoodsNames(uniqueIds) + // 合格商品 + this.inspectData["list"].forEach(item => { + if (item.qualifiedNum > 0 && item.id !== 'unrecyclable' && item.id !== 'quality_issue') { this.qualifiedList.push({ - id: item.id, - name: displayName, - shopClass: this.getShopClass(item.id), - shopId: item.shopId, - price: itemPrice, - count: qualifiedCount, - total: item.price || 0, // 使用质检时填写的总金额 - reason: '', - images: savedImages, - reasons: savedReasons + shopId: item.shopId, + count: item.qualifiedNum, + total: item.price }) } - - // 处理不合格产品 - if (unqualifiedCount > 0) { - const unqualifiedItems = [] - let index = 1 - - item.commonOrderList.forEach(commonItem => { - if (commonItem.testingStatus === 1) { - const savedImages = commonItem.testingImages ? commonItem.testingImages.split(',').filter(img => img) : [] - const savedReasons = this.parseTestingInstructions(commonItem.testingInstructions || '') - - unqualifiedItems.push({ - id: commonItem.id, - name: `${itemNames}${index}`, - shopClass: this.getShopClass(item.id), - shopId: item.shopId, - reason: '', - images: savedImages, - reasons: savedReasons - }) - index++ - } + }) + // 不合格商品(只展示质量问题) + this.inspectData["list"].forEach(item => { + if (item.id === 'quality_issue' && item.noQualifiedNum > 0) { + this.unqualifiedGroups.push({ + shopId: item.id, + count: item.noQualifiedNum, + total: item.price, + items: item.commonOrderList ? [...item.commonOrderList] : [] }) - - if (unqualifiedItems.length > 0) { - this.unqualifiedGroups.push({ - id: item.id, - name: displayName, - shopClass: this.getShopClass(item.id), - shopId: item.shopId, - price: itemPrice, - total: 0, // 不合格产品总价为0 - items: unqualifiedItems - }) - } } - - // 处理不可回收产品 - if (unrecyclableCount > 0) { - // 获取不可回收商品的理由和图片信息 - const unrecyclableCommonItem = item.commonOrderList.find(commonItem => commonItem.testingStatus === 2) - const savedImages = unrecyclableCommonItem?.testingImages ? unrecyclableCommonItem.testingImages.split(',').filter(img => img) : [] - const savedReasons = this.parseTestingInstructions(unrecyclableCommonItem?.testingInstructions || '') - + }) + // 不可回收商品 + this.inspectData["list"].forEach(item => { + if (item.id === 'unrecyclable' && item.unrecyclable > 0) { this.unrecyclableList.push({ id: item.id, - name: displayName, - shopClass: item.shopClass, - shopId: item.shopId, - price: '', // 不可回收产品不显示价格 - count: unrecyclableCount, - total: 0, - reason: '', - images: savedImages, - reasons: savedReasons + count: item.unrecyclable, + total: 0 }) } }) - - console.log('处理后的数据:', { - qualifiedList: this.qualifiedList, - unqualifiedGroups: this.unqualifiedGroups, - unrecyclableList: this.unrecyclableList - }) + }, + async fetchGoodsNames(ids) { + // 批量获取商品名称 + const nameMap = {} + for (const id of ids) { + try { + const res = await this.$api('getGoodsDetail', { goodsId: id }) + if (res && res.code === 200 && res.result) { + nameMap[id] = res.result.name + } + } catch (e) { + nameMap[id] = '未知商品' + } + } + this.goodsNameMap = nameMap + }, + getGoodsName(id) { + return this.goodsNameMap[id] || '未知商品' }, goBack() { uni.navigateBack() @@ -327,63 +269,119 @@ export default { uni.navigateBack() }, finishInspect() { - // 这里可以将最终的inspectData提交到服务器 - - this.inspectData["list"]=JSON.stringify(this.inspectData["list"], null, 2) - console.log('最终的质检数据:', this.inspectData); - // 可以调用API提交数据 - this.$api('submitQualityInfo', this.inspectData , res => { + // 校验理由必填性 + // 1. 合格产品理由可选填 + // 2. 质量问题和不可回收理由必填 + // 检查质量问题 + const qualityItem = this.inspectData["list"].find(item => item.id === 'quality_issue') + if (qualityItem && qualityItem.noQualifiedNum > 0) { + const hasReason = qualityItem.commonOrderList && qualityItem.commonOrderList.some(c => { + // 只要填写了理由或图片即可 + return (c.testingInstructions && c.testingInstructions.trim() !== '') || + (c.testingImages && c.testingImages.trim() !== '') + }) + if (!hasReason) { + uni.showToast({ title: '质量问题理由必填', icon: 'none' }) + return + } + } + // 检查不可回收 + const unrecyclableItem = this.inspectData["list"].find(item => item.id === 'unrecyclable') + if (unrecyclableItem && unrecyclableItem.unrecyclable > 0) { + const hasReason = unrecyclableItem.commonOrderList && unrecyclableItem.commonOrderList.some(c => { + return (c.testingInstructions && c.testingInstructions.trim() !== '') || + (c.testingImages && c.testingImages.trim() !== '') + }) + if (!hasReason) { + uni.showToast({ title: '不可回收理由必填', icon: 'none' }) + 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)} + console.log('最终的质检数据:', inspectDatas); + this.$api('submitQualityInfo', inspectDatas , res => { if (res && res.code === 200) { uni.showToast({ title: '质检完成', icon: 'success' }) - // 关闭其余页面回到首页 - uni.reLaunch({ - url: '/pages/component/home' - }) + uni.reLaunch({ url: '/pages/component/home' }) } }) - uni.showToast({ title: '完成质检', icon: 'success' }) }, - selectReasonForUnqualified(item,type) { - this.$api('getcheckoutReasons', { - classId: item.shopClass, - type: type - }, res => { - console.log('res', res) - if(res.code == 200){ - this.reasonOptions = res.result; - } - }) - }, selectReason(item) { - console.log('item', item) - this.currentReasonItem = item - this.currentReasonTitle = item.name - this.reasonImages = item.images || [] - this.reasonChecked = item.reasons || Array(this.reasonOptions.length).fill(false) - this.selectReasonForUnqualified(item,0) + // 始终用inspectData.list中的最新对象 + let popupItem = item + 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 + } + } 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 + } + } + this.currentReasonItem = popupItem + // 判断类型,动态设置标题 + if (popupItem.testingStatus === 1) { + this.currentReasonTitle = '质量问题' + } else if (popupItem.testingStatus === 2) { + this.currentReasonTitle = '不可回收' + } else { + this.currentReasonTitle = this.getGoodsName(popupItem.shopId || popupItem.id) + } + this.reasonImages = popupItem.images || [] + // 不在这里设置reasonChecked + this.selectReasonForUnqualified(popupItem, 0) this.lockScroll() this.$refs.reasonPopup.open() }, selectReasonForQualified(item) { this.currentReasonItem = item - this.currentReasonTitle = this.getItemName(item.id) + this.currentReasonTitle = this.getGoodsName(item.shopId || item.id) this.reasonImages = item.images || [] - this.reasonChecked = item.reasons || Array(this.reasonOptions.length).fill(false) - this.selectReasonForUnqualified(item,1) + // 不在这里设置reasonChecked + this.selectReasonForUnqualified(item, 1) this.lockScroll() this.$refs.reasonPopup.open() }, selectReasonForUnrecyclable(item) { - console.log('item', item) this.currentReasonItem = item - this.currentReasonTitle = this.getItemName(item.id) + this.currentReasonTitle = '不可回收' this.reasonImages = item.images || [] - this.reasonChecked = item.reasons || Array(this.reasonOptions.length).fill(false) - this.selectReasonForUnqualified(item,2) + // 不在这里设置reasonChecked + this.selectReasonForUnqualified(item, 2) this.lockScroll() this.$refs.reasonPopup.open() }, + selectReasonForUnqualified(item, type) { + this.$api('getcheckoutReasons', { + classId: item.shopClass, + type: type + }, res => { + if (res.code == 200) { + this.reasonOptions = res.result; + if (item.testingInstructions) { + this.reasonChecked = item.testingInstructions.split(',').map(s => s.trim()).filter(Boolean) + } else { + this.reasonChecked = [] + } + this.$nextTick(() => { + this.reasonChecked = [...this.reasonChecked] + console.log('[selectReasonForUnqualified] reasonOptions:', this.reasonOptions) + console.log('[selectReasonForUnqualified] reasonChecked:', this.reasonChecked) + }) + } + }) + }, closeReasonPopup() { this.unlockScroll() this.$refs.reasonPopup.close() @@ -397,26 +395,27 @@ export default { }) return } - + uni.chooseMedia({ count: 3 - this.reasonImages.length, // 剩余可选择数量 mediaType: ['image'], // 只选择图片 sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机 maxDuration: 30, + sizeType: [ 'compressed'], camera: 'back', success: (res) => { console.log('选择的图片:', res.tempFiles) - + // 显示上传进度 uni.showLoading({ title: '上传中...' }) - + // 处理选择的图片 const uploadPromises = res.tempFiles.map(file => { return this.uploadImageToOSS(file.tempFilePath) }) - + // 批量上传 Promise.all(uploadPromises).then(urls => { this.reasonImages = this.reasonImages.concat(urls) @@ -457,23 +456,27 @@ export default { this.reasonImages.splice(idx, 1) }, toggleReason(idx) { - console.log - this.$set(this.reasonChecked, idx, !this.reasonChecked[idx]) + const val = this.reasonOptions[idx].reason.toString() + const i = this.reasonChecked.indexOf(val) + if (i > -1) { + this.reasonChecked.splice(i, 1) + } else { + this.reasonChecked.push(val) + } + this.reasonChecked = [...this.reasonChecked] + console.log('[toggleReason] reasonChecked:', this.reasonChecked) }, saveReason() { - // 保存到当前item if (this.currentReasonItem) { + console.log('this.currentReasonItem', this.currentReasonItem) this.currentReasonItem.images = [...this.reasonImages] - this.currentReasonItem.reasons = [...this.reasonChecked] - // console.log('this.currentReasonItem', this.currentReasonItem) - // 更新inspectData中的数据 + this.currentReasonItem.testingInstructions = this.reasonChecked.join(',') this.updateInspectData() } this.closeReasonPopup() }, updateInspectData() { if (!this.inspectData || !this.currentReasonItem) return - // 获取选中的理由ID(假设理由选项的索引就是ID) const selectedReasonIds = [] this.reasonChecked.forEach((checked, index) => { @@ -481,13 +484,10 @@ export default { 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) @@ -496,14 +496,13 @@ export default { } else if (this.isUnrecyclableItem(this.currentReasonItem)) { this.updateUnrecyclableItemInspectData(testingInstructions, testingImages) } - - console.log('更新后的inspectData:', JSON.stringify(this.inspectData, null, 2)) + console.log('[updateInspectData] after update', JSON.stringify(this.inspectData, null, 2)) }, isQualifiedItem(item) { - return this.qualifiedList.some(qualified => qualified.id === item.id) + return this.qualifiedList.some(qualified => qualified.shopId === item.shopId) }, isUnqualifiedItem(item) { - return this.unqualifiedGroups.some(group => + return this.unqualifiedGroups.some(group => group.items.some(unqualified => unqualified.id === item.id) ) }, @@ -511,7 +510,7 @@ export default { return this.unrecyclableList.some(unrecyclable => unrecyclable.id === item.id) }, updateQualifiedItemInspectData(testingInstructions, testingImages) { - const inspectItem = this.inspectData.list.find(item => item.id == this.currentReasonItem.id) + const inspectItem = this.inspectData["list"].find(item => item.id == this.currentReasonItem.id) if (inspectItem && inspectItem.commonOrderList) { // 为合格的商品更新所有状态为0的项 inspectItem.commonOrderList.forEach(commonItem => { @@ -528,7 +527,7 @@ export default { 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) + 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) @@ -541,7 +540,7 @@ export default { }) }, updateUnrecyclableItemInspectData(testingInstructions, testingImages) { - const inspectItem = this.inspectData.list.find(item => item.id == this.currentReasonItem.id) + const inspectItem = this.inspectData["list"].find(item => item.id == this.currentReasonItem.id) if (inspectItem && inspectItem.commonOrderList) { // 为不可回收的商品更新所有状态为2的项 inspectItem.commonOrderList.forEach(commonItem => { @@ -567,22 +566,6 @@ export default { // 可根据实际需求刷新质检结果数据 // 例如重新请求接口或重置数据 }, - getItemName(id) { - if (this.order && this.order.commonOrderList) { - const orderItem = this.order.commonOrderList.find(item => item.id == id) - return orderItem ? (orderItem.title || '未知商品') : '未知商品' - } - return '未知商品' - }, - getShopClass(id) { - if (this.order && this.order.commonOrderList) { - // console.log('this.order', ShopClass) - const ShopClass = this.order.commonOrderList.find(item => item.id == id) - // console.log('ShopClass', ShopClass) - return ShopClass ? ShopClass.shopClass: '' - } - return '' - }, getItemBrand(id) { if (this.order && this.order.commonOrderList) { const orderItem = this.order.commonOrderList.find(item => item.id == id) @@ -590,24 +573,13 @@ export default { } return '' }, - parseTestingInstructions(instructions) { - // 解析理由ID字符串,返回布尔数组 - const reasonArray = Array(this.reasonOptions.length).fill(false) - if (instructions) { - const selectedIds = instructions.split(',').map(id => id.trim()).filter(id => id) - selectedIds.forEach(id => { - const index = parseInt(id) - if (index >= 0 && index < reasonArray.length) { - reasonArray[index] = true - } - }) - } - return reasonArray + parseTestingInstructions() { + return [] }, hasSelectedReason(item) { + // console.log('item', item) // 检查该商品是否已选择理由或上传图片 - return (item.reasons && item.reasons.some(checked => checked)) || - (item.images && item.images.length > 0) + return (item.images && item.images.length > 0) } } } @@ -619,6 +591,7 @@ export default { background: #f8f8f8; display: flex; flex-direction: column; + &.popup-open { overflow: hidden; position: fixed; @@ -626,6 +599,7 @@ export default { height: 100vh; } } + .nav-bar { display: flex; align-items: center; @@ -639,11 +613,13 @@ export default { right: 0; z-index: 999; box-sizing: border-box; - box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.03); + box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03); + .back { padding: 20rpx; margin-left: -20rpx; } + .nav-title { flex: 1; text-align: center; @@ -651,12 +627,14 @@ export default { font-weight: 500; color: #222; } + .nav-icons { display: flex; align-items: center; gap: 12px; } } + .main-content { margin-top: calc(200rpx + var(--status-bar-height)); display: flex; @@ -664,25 +642,29 @@ export default { background: none; padding-bottom: 120px; } + .result-card { background: #fff; border-radius: 24px; - box-shadow: 0 4px 24px rgba(0,0,0,0.06); + box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06); margin: 0 24px 24px 24px; padding: 24px 24px 0 24px; } + .card-title { font-size: 16px; font-weight: bold; color: #222; margin-bottom: 18px; } + .card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; } + .status-tag { background: #fff7e6; color: #ffb400; @@ -694,22 +676,28 @@ export default { display: flex; align-items: center; } -.result-row, .result-group { + +.result-row, +.result-group { margin-bottom: 18px; } + .row-main { display: flex; align-items: center; + .goods-name-section { display: flex; flex-direction: column; margin-right: 8px; + .goods-name { font-size: 14px; font-weight: bold; color: #222; line-height: 1.2; } + .goods-brand { font-size: 11px; color: #999; @@ -718,27 +706,20 @@ export default { margin-top: 2px; } } + .row-name { font-size: 14px; font-weight: bold; color: #222; margin-right: 8px; } - .row-price { - font-size: 13px; - color: #ffb400; - font-weight: bold; - margin-right: 8px; - .row-unit { - font-size: 11px; - color: #bbb; - } - } + .row-count { font-size: 13px; color: #888; margin-right: 8px; } + .row-total { font-size: 14px; color: #222; @@ -746,15 +727,18 @@ export default { margin-left: auto; } } + .row-reason { display: flex; align-items: center; margin-top: 8px; + .reason-label { font-size: 13px; color: #bbb; min-width: 80px; } + .reason-input { flex: 1; height: 36px; @@ -766,6 +750,7 @@ export default { padding-left: 12px; margin-left: 8px; } + .reason-select { flex: 1; display: flex; @@ -779,41 +764,49 @@ export default { margin-left: 8px; justify-content: flex-end; } + .reason-placeholder { color: #bbb; font-size: 14px; + &.selected { color: #52c41a; font-weight: 500; } } } + .info-card { background: #fff; border-radius: 24px; - box-shadow: 0 4px 24px rgba(0,0,0,0.06); + box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06); margin: 0 24px 24px 24px; padding: 24px 24px 0 24px; } + .info-row { display: flex; align-items: center; margin-bottom: 16px; + .info-label { font-size: 13px; color: #bbb; min-width: 80px; } + .info-value { font-size: 13px; color: #222; margin-left: 8px; } + .copy-btn { color: #ffb400; margin-left: 8px; } } + .footer-btns { position: fixed; left: 0; @@ -824,6 +817,7 @@ export default { gap: 16px; padding: 12px 16px 24px 16px; z-index: 101; + .btn-outline { flex: 1; height: 40px; @@ -836,6 +830,7 @@ export default { box-shadow: none; padding: 0 18px; } + .btn-main { flex: 1; height: 40px; @@ -849,12 +844,15 @@ export default { padding: 0 18px; } } + .reason-popup-wrapper { z-index: 10000 !important; } + .reason-popup-wrapper .uni-popup__wrapper { z-index: 10000 !important; } + .reason-popup { background: #fff; border-radius: 24px 24px 0 0; @@ -862,6 +860,7 @@ export default { height: 75vh; position: relative; z-index: 9999; + .popup-header { display: flex; align-items: center; @@ -869,27 +868,33 @@ export default { height: 60px; border-bottom: 1px solid #f0f0f0; position: relative; + .popup-close { position: absolute; left: 20px; color: #666; font-size: 16px; } + .popup-title { font-size: 18px; font-weight: 600; color: #222; } } + .popup-content { height: calc(75vh - 60px - 82px); overflow-y: auto; } + .popup-section { padding: 0 20px 24px 20px; + &:first-child { padding-top: 24px; } + .section-label { font-size: 16px; color: #222; @@ -897,29 +902,33 @@ export default { display: block; font-weight: 500; } + .img-list { display: flex; gap: 12px; margin-bottom: 32px; + .img-item { width: 80px; height: 80px; border-radius: 12px; background: #f8f8f8; position: relative; + .img { width: 100%; height: 100%; border-radius: 12px; object-fit: cover; } + .img-del { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; - background: rgba(0,0,0,0.6); + background: rgba(0, 0, 0, 0.6); color: #fff; border-radius: 50%; text-align: center; @@ -927,6 +936,7 @@ export default { font-size: 16px; font-weight: bold; } + &.add { display: flex; align-items: center; @@ -937,14 +947,17 @@ export default { } } } + .reason-row { display: flex; align-items: center; padding: 16px 0; border-bottom: 1px solid #f0f0f0; + &:last-child { border-bottom: none; } + .checkbox { width: 20px; height: 20px; @@ -953,9 +966,11 @@ export default { margin-right: 12px; background: #fff; position: relative; + &.checked { border-color: #ffb400; background: #ffb400; + &::after { content: '✓'; position: absolute; @@ -968,6 +983,7 @@ export default { } } } + .reason-text { font-size: 16px; color: #222; @@ -975,6 +991,7 @@ export default { } } } + .popup-save-btn { position: fixed; bottom: 34px; @@ -993,4 +1010,4 @@ export default { box-shadow: 0 4px 12px rgba(255, 172, 4, 0.3); } } - \ No newline at end of file + \ No newline at end of file diff --git a/pages/manager/inspect.vue b/pages/manager/inspect.vue index 221575d..fc9f034 100644 --- a/pages/manager/inspect.vue +++ b/pages/manager/inspect.vue @@ -27,7 +27,7 @@ {{ item.name }} - ¥ {{ item.price }} /件 + ¥ {{ item.price }} /{{item.unit}} {{ item.desc }} @@ -37,13 +37,16 @@ {{ item.qualified }} - + 总金额 - + 加载中... @@ -123,7 +126,6 @@ export default { searchTimer: null, brandIndexList: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'], - isPresetDataSync: false, // 标记是否为预置数据同步 } }, computed: { @@ -157,39 +159,11 @@ export default { }, methods: { initInspectResult() { - // 初始化一个空的质检结果结构 + // 只初始化空的list this.inspectResult = { id: this.order ? this.order.id : '', list: [] } - - // 如果有订单数据,基于订单创建质检结果结构 - if (this.order && this.order.commonOrderList) { - const groupedGoods = {} - this.order.commonOrderList.forEach(item => { - if (!groupedGoods[item.id]) { - groupedGoods[item.id] = { - id: item.id, - price: '', - qualifiedNum: item.num || 0, // 初始化为订单中的数量 - noQualifiedNum: 0, - unrecyclable: 0, - commonOrderList: [] - } - } - - // 每个商品只需要一个质检项 - groupedGoods[item.id].commonOrderList.push({ - id: item.id, - testingInstructions: '', - testingImages: '', - testingStatus: 0 // 初始化为合格状态 - }) - }) - - this.inspectResult.list = Object.values(groupedGoods) - console.log('初始化inspectResult:', JSON.stringify(this.inspectResult, null, 2)) - } }, // 获取分类商品数量(直接方法,避免递归) @@ -197,43 +171,17 @@ export default { if (categoryId === 'unrecyclable') { return this.getUnrecyclableCount() } - if (categoryId === 'quality_issue') { return this.getQualityIssueCount() } - - // 对于普通分类,从inspectResult中获取该分类下所有商品的合格数量总和 let totalCount = 0 - if (this.inspectResult.list && this.inspectResult.list.length > 0) { - // 遍历inspectResult中的所有商品 this.inspectResult.list.forEach(inspectItem => { - // 跳过特殊分类 - if (inspectItem.id === 'unrecyclable' || inspectItem.id === 'quality_issue') { - return - } - - // 通过商品ID查找对应的订单项,获取分类信息 - const orderItem = this.order?.commonOrderList?.find(item => item.id == inspectItem.id) - - // 如果通过订单ID没找到,尝试通过API商品ID查找 - if (!orderItem) { - // 遍历所有订单项,查找是否有shopId匹配当前inspectItem.id的 - const matchingOrderItem = this.order?.commonOrderList?.find(item => item.shopId == inspectItem.id) - if (matchingOrderItem && matchingOrderItem.shopClass === categoryId) { - totalCount += inspectItem.qualifiedNum || 0 - return - } - } - - // 如果找到了订单项,检查分类是否匹配 - if (orderItem && orderItem.shopClass === categoryId) { - // 累加该商品的合格数量 + if (inspectItem.categoryId === categoryId) { totalCount += inspectItem.qualifiedNum || 0 } }) } - return totalCount }, @@ -287,7 +235,6 @@ export default { }, updateCurrentGoods() { const currentCategoryId = this.categories[this.currentCategory]?.id - // 不可回收分类内容 if (currentCategoryId === 'unrecyclable') { // 从inspectResult中获取不可回收的数量 @@ -306,7 +253,6 @@ export default { }] return } - // 质量问题分类内容 if (currentCategoryId === 'quality_issue') { // 从inspectResult中获取质量问题的数量 @@ -325,47 +271,34 @@ export default { }] return } - // 从API获取的商品数据 const categoryGoods = this.allProducts[currentCategoryId] || [] - - // 将API商品数据转换为质检页面格式 + // 将API商品数据转换为质检页面格式,并合并inspectResult.list中已选状态(shopId和id双向查找) const goodsList = categoryGoods.map((item, index) => { - // 从订单数据中查找对应的商品,获取预置数量 + // 从订单数据中查找对应的商品 const orderItem = this.getOrderItemByProductId(item.id) - const presetQuantity = orderItem ? (orderItem.num || 0) : 0 - - // 优先使用订单中的商品ID,如果没有则使用API商品ID let itemId = item.id - - // 尝试从订单数据中找到对应的商品ID if (orderItem && orderItem.id) { - itemId = orderItem.id // 使用订单中的商品ID + itemId = orderItem.id } - - // 从inspectResult中获取用户已经修改的数量 - const inspectItem = this.inspectResult.list?.find(listItem => listItem.id == itemId) - const userModifiedQuantity = inspectItem ? inspectItem.qualifiedNum : 0 - - // 优先使用用户修改的数量,如果没有则使用预置数量 - const displayQuantity = userModifiedQuantity > 0 ? userModifiedQuantity : presetQuantity - + const inspectItem = this.inspectResult.list?.find(listItem => + listItem.shopId == item.id || listItem.shopId == itemId || listItem.id == item.id || listItem.id == itemId + ) return { id: item.id, image: item.image || '/static/回收/衣物.png', name: item.name, price: item.price || 0, desc: item.service || '允许脏破烂,160码以上', - qualified: displayQuantity, // 优先使用用户修改的数量 - amount: inspectItem ? inspectItem.price : (orderItem ? orderItem.estimatedPrice : ''), - originalNum: presetQuantity, // 设置原始数量 + qualified: inspectItem ? inspectItem.qualifiedNum : 0, + amount: inspectItem ? inspectItem.price : '', // 只用inspectResult里的金额 + originalNum: 0, estimatedPrice: orderItem ? orderItem.estimatedPrice : 0, originalId: item.id, - isPin: item.isPin || 'N', // 添加品牌标识 - orderItem: orderItem // 保存订单项引用,方便后续使用 + isPin: item.isPin || 'N', + orderItem: orderItem } }) - this.currentGoods = goodsList }, @@ -374,20 +307,10 @@ export default { if (!this.order || !this.order.commonOrderList) { return null } - - // 先通过商品ID直接匹配 - let orderItem = this.order.commonOrderList.find(item => item.id == productId) - - // 如果没找到,尝试通过shopId匹配 - if (!orderItem) { - orderItem = this.order.commonOrderList.find(item => item.shopId == productId) - } - - return orderItem + // 支持id和shopId双向查找 + return this.order.commonOrderList.find(item => item.id == productId || item.shopId == productId) }, - - goBack() { uni.navigateBack() }, @@ -408,8 +331,9 @@ export default { inspectResult: this.inspectResult, order: this.order // 同时传递订单信息 } - + console.log('resultDataStr:', resultData) const resultDataStr = encodeURIComponent(JSON.stringify(resultData)) + uni.navigateTo({ url: `/pages/manager/inspect-result?resultData=${resultDataStr}` }) @@ -421,38 +345,36 @@ export default { message: '没有质检数据' } } - for (const item of this.inspectResult.list) { - // 跳过不可回收和质量问题分类的检查 + // 不可回收和质量问题不需要校验金额 if (item.id === 'unrecyclable' || item.id === 'quality_issue') { continue } - - // 获取商品信息用于显示错误消息 - const orderItem = this.order.commonOrderList.find(orderGoods => orderGoods.id == item.id) - const brandName = orderItem ? (orderItem.title+' '+orderItem.pinName || orderItem.title || '未知商品') : '未知商品' - + // 只判断是否填写了commonOrderList(即有质检结果) + if (!item.commonOrderList || item.commonOrderList.length === 0) { + return { + isValid: false, + message: '有商品未完成质检选择' + } + } // 检查是否有空的testingStatus const hasEmptyStatus = item.commonOrderList.some(commonItem => commonItem.testingStatus === '' || commonItem.testingStatus === null || commonItem.testingStatus === undefined ) - if (hasEmptyStatus) { return { isValid: false, - message: `${brandName} 还未完成质检选择` + message: '有商品未完成质检选择' } } - - // 检查价格是否为空 + // 检查总金额(price)是否填写(不可回收和质量问题不校验) if (!item.price || item.price === 0 || item.price === '') { return { isValid: false, - message: `${brandName} 还未填写总金额` + message: '有商品未填写总金额' } } } - return { isValid: true, message: '' @@ -466,7 +388,7 @@ export default { if (categoryId === 'unrecyclable' || categoryId === 'quality_issue') { // 不可回收和质量问题分类直接更新商品列表 - this.updateCurrentGoods() + this.updateCurrentGoods() return } @@ -480,183 +402,219 @@ export default { }, changeNum(item, key, delta) { if (key === 'qualified') { + const currentCategoryId = this.categories[this.currentCategory]?.id // 如果是增加数量 if (delta > 0) { - // 对于不可回收和质量问题分类,直接增加数量,不弹出品牌选择 if (item.id === 'unrecyclable-1' || item.id === 'quality-issue-1') { const newQualified = Math.max(0, (item.qualified || 0) + delta) this.$set(item, 'qualified', newQualified) - this.updateInspectResult(item, 'qualified', delta) + this.updateInspectResult(item, 'qualified', delta, currentCategoryId) this.$forceUpdate() return } - - // 其他商品弹出品牌选择弹窗 - this.pendingBrandIndex = this.currentGoods.findIndex(goods => goods.id === item.id) - this.getGoodsBrandList(item.id) - this.showBrandPopup = true - return } - const newQualified = Math.max(0, (item.qualified || 0) + delta) this.$set(item, 'qualified', newQualified) - // 更新inspectResult对象 - this.updateInspectResult(item, 'qualified', delta) - // 强制更新categories计算属性,使左侧分类数字变化 + this.updateInspectResult(item, 'qualified', delta, currentCategoryId) + // 新增:如果数量为0,移除该商品对象(包括不可回收和质量问题) + if (newQualified === 0) { + this.removeInspectItem(item) + } this.$forceUpdate() console.log('更新后的inspectResult:', JSON.stringify(this.inspectResult, null, 2)) } }, - updateInspectResult(item, type, delta) { + // 修改:移除商品对象方法,支持不可回收和质量问题 + removeInspectItem(item) { + // 判断不可回收和质量问题 + if (item.id === 'unrecyclable-1' || item.id === 'unrecyclable') { + const idx = this.inspectResult.list.findIndex(listItem => listItem.id === 'unrecyclable') + if (idx !== -1) { + this.inspectResult.list.splice(idx, 1) + } + return + } + if (item.id === 'quality-issue-1' || item.id === 'quality_issue') { + const idx = this.inspectResult.list.findIndex(listItem => listItem.id === 'quality_issue') + if (idx !== -1) { + this.inspectResult.list.splice(idx, 1) + } + return + } + let itemId = item.originalId || item.id + const orderItem = this.getOrderItemByProductId(itemId) + if (orderItem && orderItem.id) { + itemId = orderItem.id + } + // shopId 匹配 + const idx = this.inspectResult.list.findIndex(listItem => listItem.shopId == (orderItem ? (orderItem.shopId || orderItem.id) : itemId)) + if (idx !== -1) { + this.inspectResult.list.splice(idx, 1) + } + }, + updateInspectResult(item, type, delta, currentCategoryId) { // 处理不可回收分类 if (item.id === 'unrecyclable-1') { - // 找到或创建不可回收的inspectResult项 let inspectItem = this.inspectResult.list.find(listItem => listItem.id === 'unrecyclable') - - if (!inspectItem) { + if (!inspectItem && delta > 0) { inspectItem = { id: 'unrecyclable', - price: '', + price: 0, qualifiedNum: 0, noQualifiedNum: 0, unrecyclable: 0, - commonOrderList: [] + shopId: '', + pinId: '', + categoryId: '', + commonOrderList: [ + { + testingInstructions: '', + testingImages: '', + testingStatus: 2 + } + ] } this.inspectResult.list.push(inspectItem) } - + if (!inspectItem) return if (type === 'qualified' && delta > 0) { inspectItem.unrecyclable++ } else if (type === 'qualified' && delta < 0) { inspectItem.unrecyclable = Math.max(0, inspectItem.unrecyclable - 1) + // 新增:如果减到0,移除该对象 + if (inspectItem.unrecyclable === 0) { + const idx = this.inspectResult.list.findIndex(listItem => listItem === inspectItem) + if (idx !== -1) { + this.inspectResult.list.splice(idx, 1) + } + return + } } - - console.log('不可回收数量更新:', inspectItem.unrecyclable) + console.log('不可回收对象:', inspectItem) return } - - // 处理质量问题分类 if (item.id === 'quality-issue-1') { - // 找到或创建质量问题的inspectResult项 let inspectItem = this.inspectResult.list.find(listItem => listItem.id === 'quality_issue') - - if (!inspectItem) { + if (!inspectItem && delta > 0) { inspectItem = { id: 'quality_issue', - price: '', + price: 0, qualifiedNum: 0, noQualifiedNum: 0, unrecyclable: 0, - commonOrderList: [] + shopId: '', + pinId: '', + categoryId: '', + commonOrderList: [ + { + testingInstructions: '', + testingImages: '', + testingStatus: 1 + } + ] } this.inspectResult.list.push(inspectItem) } - + if (!inspectItem) return if (type === 'qualified' && delta > 0) { inspectItem.noQualifiedNum++ } else if (type === 'qualified' && delta < 0) { inspectItem.noQualifiedNum = Math.max(0, inspectItem.noQualifiedNum - 1) + // 新增:如果减到0,移除该对象 + if (inspectItem.noQualifiedNum === 0) { + const idx = this.inspectResult.list.findIndex(listItem => listItem === inspectItem) + if (idx !== -1) { + this.inspectResult.list.splice(idx, 1) + } + return + } } - - console.log('质量问题数量更新:', inspectItem.noQualifiedNum) + console.log('质量问题对象:', inspectItem) return } - - // 找到或创建对应的inspectResult项 - // 优先使用订单中的商品ID,如果没有则使用API商品ID let itemId = item.originalId || item.id - - // 尝试从订单数据中找到对应的商品ID const orderItem = this.getOrderItemByProductId(itemId) if (orderItem && orderItem.id) { - itemId = orderItem.id // 使用订单中的商品ID + itemId = orderItem.id } - - let inspectItem = this.inspectResult.list.find(listItem => listItem.id == itemId) - - // 如果不存在,动态创建 - if (!inspectItem) { + let inspectItem = this.inspectResult.list.find(listItem => listItem.shopId == (orderItem ? (orderItem.shopId || orderItem.id) : itemId)) + if (!inspectItem && delta > 0) { inspectItem = { - id: itemId, - price: '', + price: 0, qualifiedNum: 0, noQualifiedNum: 0, unrecyclable: 0, - commonOrderList: [] + shopId: orderItem ? (orderItem.shopId || orderItem.id) : itemId, + pinId: '', + categoryId: currentCategoryId || '', // 直接用当前分类id + commonOrderList: [ + { + testingInstructions: '', + testingImages: '', + testingStatus: 0 + } + ] } this.inspectResult.list.push(inspectItem) - console.log('新增商品到inspectResult:', itemId) - } - - // 如果是预置数据同步,直接设置数量 - if (type === 'qualified' && delta > 0 && this.isPresetDataSync) { - inspectItem.qualifiedNum = delta - return } - + if (!inspectItem) return if (type === 'qualified' && delta > 0) { - // 增加合格数量:直接更新数量 inspectItem.qualifiedNum++ - console.log(`为商品 ${itemId} 增加数量,当前合格数量: ${inspectItem.qualifiedNum}`) } else if (type === 'qualified' && delta < 0) { - // 减少合格数量:直接更新数量 inspectItem.qualifiedNum = Math.max(0, inspectItem.qualifiedNum - 1) - console.log(`为商品 ${itemId} 减少数量,当前合格数量: ${inspectItem.qualifiedNum}`) + // 新增:如果减到0,移除该商品对象 + if (inspectItem.qualifiedNum === 0) { + const idx = this.inspectResult.list.findIndex(listItem => listItem === inspectItem) + if (idx !== -1) { + this.inspectResult.list.splice(idx, 1) + } + return + } } console.log('更新后的inspectResult:', JSON.stringify(this.inspectResult, null, 2)) }, getInspectPrice(item) { - // 获取inspectResult中对应商品的price - if (item.id === 'unrecyclable-1' || item.id === 'quality-issue-1') { - return '' + // 优化:不可回收和质量问题通过id匹配 + if (item.id === 'unrecyclable-1' || item.id === 'unrecyclable') { + const inspectItem = this.inspectResult.list?.find(listItem => listItem.id === 'unrecyclable') + return inspectItem ? inspectItem.price : '' } - - // 优先使用订单中的商品ID,如果没有则使用API商品ID - let itemId = item.originalId || item.id - - // 尝试从订单数据中找到对应的商品ID - const orderItem = this.getOrderItemByProductId(itemId) - if (orderItem && orderItem.id) { - itemId = orderItem.id // 使用订单中的商品ID + if (item.id === 'quality-issue-1' || item.id === 'quality_issue') { + const inspectItem = this.inspectResult.list?.find(listItem => listItem.id === 'quality_issue') + return inspectItem ? inspectItem.price : '' } - - const inspectItem = this.inspectResult.list?.find(listItem => listItem.id == itemId) + // 普通商品 + const inspectItem = this.inspectResult.list?.find(listItem => listItem.shopId == item.id) return inspectItem ? inspectItem.price : '' }, updateInspectPrice(item, event) { - // 更新inspectResult中对应商品的price - if (item.id === 'unrecyclable-1' || item.id === 'quality-issue-1') { + // 优化:不可回收和质量问题通过id匹配 + if (item.id === 'unrecyclable-1' || item.id === 'unrecyclable') { + const inspectItem = this.inspectResult.list?.find(listItem => listItem.id === 'unrecyclable') + if (!inspectItem) return + inspectItem.price = parseFloat(event.detail.value) || 0 return } - - // 优先使用订单中的商品ID,如果没有则使用API商品ID + if (item.id === 'quality-issue-1' || item.id === 'quality_issue') { + const inspectItem = this.inspectResult.list?.find(listItem => listItem.id === 'quality_issue') + if (!inspectItem) return + inspectItem.price = parseFloat(event.detail.value) || 0 + return + } + // 普通商品 let itemId = item.originalId || item.id - - // 尝试从订单数据中找到对应的商品ID const orderItem = this.getOrderItemByProductId(itemId) if (orderItem && orderItem.id) { itemId = orderItem.id // 使用订单中的商品ID } - - let inspectItem = this.inspectResult.list?.find(listItem => listItem.id == itemId) - - // 如果不存在,动态创建 - if (!inspectItem) { - inspectItem = { - id: itemId, - price: '', - qualifiedNum: 0, - noQualifiedNum: 0, - unrecyclable: 0, - commonOrderList: [] - } - this.inspectResult.list.push(inspectItem) - } - + // 只查找,不新建 + let inspectItem = this.inspectResult.list?.find(listItem => listItem.shopId == (orderItem ? (orderItem.shopId || orderItem.id) : itemId)) + if (!inspectItem) return // 没有就不处理 const newPrice = parseFloat(event.detail.value) || 0 inspectItem.price = newPrice console.log('更新价格:', itemId, newPrice) + console.log('当前商品对象:', inspectItem) }, loadMoreGoods() { @@ -767,7 +725,7 @@ export default { if (item) { const newQualified = Math.max(0, (item.qualified || 0) + 1) this.$set(item, 'qualified', newQualified) - this.updateInspectResult(item, 'qualified', 1) + this.updateInspectResult(item, 'qualified', 1, this.categories[this.currentCategory]?.id) // 强制更新categories计算属性,使左侧分类数字变化 this.$forceUpdate() } @@ -1379,3 +1337,5 @@ export default { + + diff --git a/pages/manager/order-detail.vue b/pages/manager/order-detail.vue index 30ae8f8..026f2f3 100644 --- a/pages/manager/order-detail.vue +++ b/pages/manager/order-detail.vue @@ -83,8 +83,8 @@ {{ item.pinName }} {{ item.details }} - ¥{{ item.onePrice }} /件 - ¥{{ getSinglePriceRange(item.estimatedPrice, item.num) }} /件 + ¥{{ item.onePrice }} /{{item.unit}} + ¥{{ getSinglePriceRange(item.estimatedPrice, item.num) }} /{{item.unit}} x{{ item.num }} @@ -125,8 +125,8 @@ {{ item.pinName }} {{ item.details }} - ¥{{ item.onePrice }} /件 - ¥{{ getSinglePriceRange(item.estimatedPrice, item.num) }} /件 + ¥{{ item.onePrice }} /{{item.unit}} + ¥{{ getSinglePriceRange(item.estimatedPrice, item.num) }} /{{item.unit}} x{{ item.num }} @@ -170,8 +170,8 @@ {{ item.pinName }} {{ item.details }} - ¥{{ item.onePrice }} /件 - ¥{{ getSinglePriceRange(item.estimatedPrice, item.num) }} /件 + ¥{{ item.onePrice }} /{{item.unit}} + ¥{{ getSinglePriceRange(item.estimatedPrice, item.num) }} /{{item.unit}} x{{ item.num }} diff --git a/pages/manager/order.vue b/pages/manager/order.vue index 05d2d4e..acb0859 100644 --- a/pages/manager/order.vue +++ b/pages/manager/order.vue @@ -350,13 +350,13 @@ export default { // if (state === 3) { // return { label: '已取消', class: 'gray' } // } - if ((status === 1||status === 0) && state != 3) { + if ((status === 1||status === 0) && state != 3 && state != 4) { return { label: '已预约', class: 'green' } } else if (state === 1) { return { label: '待质检', class: 'orange' } } else if (status === 3) { return { label: '已结款', class: 'blue' } - } else if (state ===4) { + } else if (state === 4) { return { label: '已驳回', class: 'red' } } return { label: '未知状态', class: 'gray' } diff --git a/pages/manager/user.vue b/pages/manager/user.vue index 8ad4f07..4770bf8 100644 --- a/pages/manager/user.vue +++ b/pages/manager/user.vue @@ -21,7 +21,8 @@ 取消 - + @@ -41,10 +42,10 @@