爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1012 lines
30 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="inspect-result-container" :class="{ 'popup-open': isPopupOpen }">
  3. <!-- 顶部导航栏 -->
  4. <view class="nav-bar">
  5. <view class="back" @tap="goBack">
  6. <uni-icons type="left" size="20" color="#222" />
  7. </view>
  8. <text class="nav-title">步骤二合格质检</text>
  9. <view class="nav-icons">
  10. <uni-icons type="more" size="24" color="#222" />
  11. </view>
  12. </view>
  13. <view class="main-content">
  14. <!-- 合格产品卡片 -->
  15. <view v-if="hasQualifiedItems" class="result-card">
  16. <view class="card-title">合格产品</view>
  17. <view v-for="item in qualifiedList" :key="item.shopId" class="result-row">
  18. <view class="row-main">
  19. <view class="goods-name-section">
  20. <text class="goods-name">{{ item.shopId ? getGoodsName(item.shopId) : (item.id === 'unrecyclable' ? '不可回收'
  21. : (item.id === 'quality_issue' ? '质量问题' : ''))}}</text>
  22. <text class="goods-brand">{{ getItemBrand(item.shopId) }}</text>
  23. </view>
  24. <text class="row-count">x{{ item.count }}</text>
  25. <text class="row-total">¥{{ item.total }}</text>
  26. </view>
  27. <view class="row-reason">
  28. <text class="reason-label">{{ getGoodsName(item.shopId) }}</text>
  29. <view class="reason-select" @tap="selectReasonForQualified(item)">
  30. <text class="reason-placeholder" :class="{ 'selected': hasSelectedReason(item) }">
  31. {{ hasSelectedReason(item) ? '已选择' : '请选择理由(选填)' }}
  32. </text>
  33. <uni-icons type="right" size="18" color="#bbb" />
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- 不合格产品卡片 -->
  39. <view v-if="hasUnqualifiedItems" class="result-card">
  40. <view class="card-title">不合格产品</view>
  41. <view v-for="group in unqualifiedGroups" :key="group.shopId" class="result-group">
  42. <view class="row-main">
  43. <view class="goods-name-section">
  44. <text class="goods-name">质量问题</text>
  45. <text class="goods-brand"></text>
  46. </view>
  47. <text class="row-count">x{{ group.count }}</text>
  48. <text class="row-total">¥{{ group.total }}</text>
  49. </view>
  50. <!-- 选择理由模块 -->
  51. <view v-if="inspectData && inspectData.list">
  52. <view v-for="item in (inspectData.list.find(i => i.id === 'quality_issue')?.commonOrderList || [])"
  53. :key="item.id || item.testingStatus" class="row-reason">
  54. <text class="reason-label">质量问题</text>
  55. <view class="reason-select" @tap="selectReason(item)">
  56. <text class="reason-placeholder" :class="{ 'selected': hasSelectedReason(item) }">
  57. {{ hasSelectedReason(item) ? '已选择' : '请选择理由' }}
  58. </text>
  59. <uni-icons type="right" size="18" color="#bbb" />
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <!-- 不可回收产品卡片 -->
  66. <view v-if="hasUnrecyclableItems" class="result-card">
  67. <view class="card-title">不可回收产品</view>
  68. <view v-for="item in unrecyclableList" :key="item.id" class="result-row">
  69. <view class="row-main">
  70. <view class="goods-name-section">
  71. <text class="goods-name">不可回收</text>
  72. <text class="goods-brand"></text>
  73. </view>
  74. <text class="row-count">x{{ item.count }}</text>
  75. <text class="row-total">¥{{ item.total }}</text>
  76. </view>
  77. <view class="row-reason">
  78. <text class="reason-label">不可回收</text>
  79. <view class="reason-select" @tap="selectReasonForUnrecyclable(item)">
  80. <text class="reason-placeholder" :class="{ 'selected': hasSelectedReason(item) }">
  81. {{ hasSelectedReason(item) ? '已选择' : '请选择理由' }}
  82. </text>
  83. <uni-icons type="right" size="18" color="#bbb" />
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <!-- 回收信息卡片 -->
  89. <view class="result-card info-card">
  90. <view class="card-title-row">
  91. <text class="card-title">回收信息</text>
  92. <view class="status-tag">待质检</view>
  93. </view>
  94. <view class="info-row">
  95. <text class="info-label">订单编号</text>
  96. <text class="info-value copy-btn">{{ order?.ordeNo || 'RE82738127861525' }} 复制</text>
  97. </view>
  98. <view class="info-row">
  99. <text class="info-label">取件时间</text>
  100. <text class="info-value">{{ order?.goTime || '2025-03-20 11:00' }}</text>
  101. </view>
  102. </view>
  103. </view>
  104. <!-- 底部操作按钮 -->
  105. <view class="footer-btns">
  106. <button class="btn-outline" @tap="goPrev">上一步</button>
  107. <button class="btn-main" @tap="finishInspect">完成质检</button>
  108. </view>
  109. <!-- 理由弹窗 -->
  110. <uni-popup ref="reasonPopup" type="bottom" :mask-click="false" :safe-area="false" class="reason-popup-wrapper">
  111. <view class="reason-popup">
  112. <view class="popup-header">
  113. <text class="popup-close" @tap="closeReasonPopup">关闭</text>
  114. <text class="popup-title">{{ currentReasonTitle }}</text>
  115. </view>
  116. <scroll-view class="popup-content" scroll-y="true">
  117. <view class="popup-section">
  118. <text class="section-label">上传图片</text>
  119. <view class="img-list">
  120. <view class="img-item add" @tap="addReasonImg">
  121. <uni-icons type="plusempty" size="32" color="#bbb" />
  122. </view>
  123. <view v-for="(img, idx) in reasonImages" :key="idx" class="img-item">
  124. <image :src="img" class="img" />
  125. <view class="img-del" @tap="removeReasonImg(idx)">×</view>
  126. </view>
  127. </view>
  128. </view>
  129. <view class="popup-section">
  130. <text class="section-label">选择理由</text>
  131. <view v-for="(item, index) in reasonOptions" :key="item.id" class="reason-row" @tap="toggleReason(index)">
  132. <view :class="['checkbox', { checked: reasonChecked.includes(item.reason) }]" />
  133. <text class="reason-text">{{ item.reason }}</text>
  134. </view>
  135. </view>
  136. </scroll-view>
  137. <button class="popup-save-btn" @tap="saveReason">保存</button>
  138. </view>
  139. </uni-popup>
  140. </view>
  141. </template>
  142. <script>
  143. import pullRefreshMixin from '../mixins/pullRefreshMixin.js'
  144. import OSS from '@/utils/oss-upload/oss/index.js'
  145. export default {
  146. mixins: [pullRefreshMixin],
  147. data() {
  148. return {
  149. inspectData: null, // 从步骤一传过来的质检数据
  150. order: null, // 订单数据
  151. qualifiedList: [],
  152. unqualifiedGroups: [],
  153. unrecyclableList: [],
  154. goodsNameMap: {}, // 商品id => 名称
  155. reasonPopupVisible: false,
  156. currentReasonTitle: '',
  157. reasonImages: [],
  158. reasonOptions: [],
  159. reasonChecked: [],
  160. currentReasonItem: null,
  161. isPopupOpen: false // 控制弹窗状态
  162. }
  163. },
  164. computed: {
  165. hasQualifiedItems() {
  166. return this.qualifiedList && this.qualifiedList.length > 0
  167. },
  168. hasUnqualifiedItems() {
  169. return this.unqualifiedGroups && this.unqualifiedGroups.length > 0
  170. },
  171. hasUnrecyclableItems() {
  172. return this.unrecyclableList && this.unrecyclableList.length > 0
  173. }
  174. },
  175. onLoad(options) {
  176. // 接收质检数据和订单数据
  177. if (options && options.resultData) {
  178. try {
  179. const resultData = JSON.parse(decodeURIComponent(options.resultData))
  180. this.inspectData = resultData.inspectResult
  181. this.order = resultData.order
  182. this.processInspectData()
  183. } catch (error) {
  184. console.error('解析数据失败:', error)
  185. }
  186. }
  187. if (options && options.inspectData && !options.resultData) {
  188. try {
  189. this.inspectData = JSON.parse(decodeURIComponent(options.inspectData))
  190. this.processInspectData()
  191. } catch (error) {
  192. console.error('解析质检数据失败:', error)
  193. }
  194. }
  195. },
  196. methods: {
  197. async processInspectData() {
  198. if (!this.inspectData || !this.inspectData["list"]) return
  199. this.qualifiedList = []
  200. this.unqualifiedGroups = []
  201. this.unrecyclableList = []
  202. // 只收集普通商品的 shopId 作为 goodsId
  203. const allIds = []
  204. this.inspectData["list"].forEach(item => {
  205. if (item.shopId && item.id !== 'unrecyclable' && item.id !== 'quality_issue') {
  206. allIds.push(item.shopId)
  207. }
  208. })
  209. console.log('allIds', allIds)
  210. const uniqueIds = Array.from(new Set(allIds.filter(Boolean)))
  211. console.log('uniqueIds', uniqueIds)
  212. await this.fetchGoodsNames(uniqueIds)
  213. // 合格商品
  214. this.inspectData["list"].forEach(item => {
  215. if (item.qualifiedNum > 0 && item.id !== 'unrecyclable' && item.id !== 'quality_issue') {
  216. this.qualifiedList.push({
  217. shopId: item.shopId,
  218. count: item.qualifiedNum,
  219. total: item.price
  220. })
  221. }
  222. })
  223. // 不合格商品(只展示质量问题)
  224. this.inspectData["list"].forEach(item => {
  225. if (item.id === 'quality_issue' && item.noQualifiedNum > 0) {
  226. this.unqualifiedGroups.push({
  227. shopId: item.id,
  228. count: item.noQualifiedNum,
  229. total: item.price,
  230. items: item.commonOrderList ? [...item.commonOrderList] : []
  231. })
  232. }
  233. })
  234. // 不可回收商品
  235. this.inspectData["list"].forEach(item => {
  236. if (item.id === 'unrecyclable' && item.unrecyclable > 0) {
  237. this.unrecyclableList.push({
  238. id: item.id,
  239. count: item.unrecyclable,
  240. total: 0
  241. })
  242. }
  243. })
  244. },
  245. async fetchGoodsNames(ids) {
  246. // 批量获取商品名称
  247. const nameMap = {}
  248. for (const id of ids) {
  249. try {
  250. const res = await this.$api('getGoodsDetail', { goodsId: id })
  251. if (res && res.code === 200 && res.result) {
  252. nameMap[id] = res.result.name
  253. }
  254. } catch (e) {
  255. nameMap[id] = '未知商品'
  256. }
  257. }
  258. this.goodsNameMap = nameMap
  259. },
  260. getGoodsName(id) {
  261. return this.goodsNameMap[id] || '未知商品'
  262. },
  263. goBack() {
  264. uni.navigateBack()
  265. },
  266. goPrev() {
  267. uni.navigateBack()
  268. },
  269. finishInspect() {
  270. // 校验理由必填性
  271. // 1. 合格产品理由可选填
  272. // 2. 质量问题和不可回收理由必填
  273. // 检查质量问题
  274. const qualityItem = this.inspectData["list"].find(item => item.id === 'quality_issue')
  275. if (qualityItem && qualityItem.noQualifiedNum > 0) {
  276. const hasReason = qualityItem.commonOrderList && qualityItem.commonOrderList.some(c => {
  277. // 只要填写了理由或图片即可
  278. return (c.testingInstructions && c.testingInstructions.trim() !== '') ||
  279. (c.testingImages && c.testingImages.trim() !== '')
  280. })
  281. if (!hasReason) {
  282. uni.showToast({ title: '质量问题理由必填', icon: 'none' })
  283. return
  284. }
  285. }
  286. // 检查不可回收
  287. const unrecyclableItem = this.inspectData["list"].find(item => item.id === 'unrecyclable')
  288. if (unrecyclableItem && unrecyclableItem.unrecyclable > 0) {
  289. const hasReason = unrecyclableItem.commonOrderList && unrecyclableItem.commonOrderList.some(c => {
  290. return (c.testingInstructions && c.testingInstructions.trim() !== '') ||
  291. (c.testingImages && c.testingImages.trim() !== '')
  292. })
  293. if (!hasReason) {
  294. uni.showToast({ title: '不可回收理由必填', icon: 'none' })
  295. return
  296. }
  297. }
  298. // 推荐方案一
  299. // console.log('this.inspectData["list"]', this.inspectData["list"])
  300. // 推荐方案一
  301. // this.inspectData["list"].forEach(item => {
  302. // console.log('item1', item)
  303. // // delete item['categoryId']
  304. // })
  305. // 其余逻辑不变
  306. const inspectDatas = {...this.inspectData,list:JSON.stringify(this.inspectData["list"], null, 2)}
  307. console.log('最终的质检数据:', inspectDatas);
  308. this.$api('submitQualityInfo', inspectDatas , res => {
  309. if (res && res.code === 200) {
  310. uni.showToast({ title: '质检完成', icon: 'success' })
  311. uni.reLaunch({ url: '/pages/component/home' })
  312. }
  313. })
  314. uni.showToast({ title: '完成质检', icon: 'success' })
  315. },
  316. selectReason(item) {
  317. // 始终用inspectData.list中的最新对象
  318. let popupItem = item
  319. if (item.testingStatus === 1) {
  320. const qualityItem = this.inspectData["list"].find(i => i.id === 'quality_issue')
  321. if (qualityItem && qualityItem.commonOrderList) {
  322. popupItem = qualityItem.commonOrderList.find(i => i.id === item.id) || item
  323. }
  324. } else if (item.testingStatus === 2) {
  325. const unrecyclableItem = this.inspectData["list"].find(i => i.id === 'unrecyclable')
  326. if (unrecyclableItem && unrecyclableItem.commonOrderList) {
  327. popupItem = unrecyclableItem.commonOrderList.find(i => i.id === item.id) || item
  328. }
  329. }
  330. this.currentReasonItem = popupItem
  331. // 判断类型,动态设置标题
  332. if (popupItem.testingStatus === 1) {
  333. this.currentReasonTitle = '质量问题'
  334. } else if (popupItem.testingStatus === 2) {
  335. this.currentReasonTitle = '不可回收'
  336. } else {
  337. this.currentReasonTitle = this.getGoodsName(popupItem.shopId || popupItem.id)
  338. }
  339. this.reasonImages = popupItem.images || []
  340. // 不在这里设置reasonChecked
  341. this.selectReasonForUnqualified(popupItem, 0)
  342. this.lockScroll()
  343. this.$refs.reasonPopup.open()
  344. },
  345. selectReasonForQualified(item) {
  346. this.currentReasonItem = item
  347. this.currentReasonTitle = this.getGoodsName(item.shopId || item.id)
  348. this.reasonImages = item.images || []
  349. // 不在这里设置reasonChecked
  350. this.selectReasonForUnqualified(item, 1)
  351. this.lockScroll()
  352. this.$refs.reasonPopup.open()
  353. },
  354. selectReasonForUnrecyclable(item) {
  355. this.currentReasonItem = item
  356. this.currentReasonTitle = '不可回收'
  357. this.reasonImages = item.images || []
  358. // 不在这里设置reasonChecked
  359. this.selectReasonForUnqualified(item, 2)
  360. this.lockScroll()
  361. this.$refs.reasonPopup.open()
  362. },
  363. selectReasonForUnqualified(item, type) {
  364. this.$api('getcheckoutReasons', {
  365. classId: item.shopClass,
  366. type: type
  367. }, res => {
  368. if (res.code == 200) {
  369. this.reasonOptions = res.result;
  370. if (item.testingInstructions) {
  371. this.reasonChecked = item.testingInstructions.split(',').map(s => s.trim()).filter(Boolean)
  372. } else {
  373. this.reasonChecked = []
  374. }
  375. this.$nextTick(() => {
  376. this.reasonChecked = [...this.reasonChecked]
  377. console.log('[selectReasonForUnqualified] reasonOptions:', this.reasonOptions)
  378. console.log('[selectReasonForUnqualified] reasonChecked:', this.reasonChecked)
  379. })
  380. }
  381. })
  382. },
  383. closeReasonPopup() {
  384. this.unlockScroll()
  385. this.$refs.reasonPopup.close()
  386. },
  387. addReasonImg() {
  388. // 检查是否已达到最大数量限制
  389. if (this.reasonImages.length >= 3) {
  390. uni.showToast({
  391. title: '最多只能上传3张图片',
  392. icon: 'none'
  393. })
  394. return
  395. }
  396. uni.chooseMedia({
  397. count: 3 - this.reasonImages.length, // 剩余可选择数量
  398. mediaType: ['image'], // 只选择图片
  399. sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机
  400. maxDuration: 30,
  401. sizeType: [ 'compressed'],
  402. camera: 'back',
  403. success: (res) => {
  404. console.log('选择的图片:', res.tempFiles)
  405. // 显示上传进度
  406. uni.showLoading({
  407. title: '上传中...'
  408. })
  409. // 处理选择的图片
  410. const uploadPromises = res.tempFiles.map(file => {
  411. return this.uploadImageToOSS(file.tempFilePath)
  412. })
  413. // 批量上传
  414. Promise.all(uploadPromises).then(urls => {
  415. this.reasonImages = this.reasonImages.concat(urls)
  416. uni.hideLoading()
  417. uni.showToast({
  418. title: '上传成功',
  419. icon: 'success'
  420. })
  421. }).catch(error => {
  422. console.error('上传失败:', error)
  423. uni.hideLoading()
  424. uni.showToast({
  425. title: '上传失败,请重试',
  426. icon: 'none'
  427. })
  428. })
  429. },
  430. fail: (error) => {
  431. console.error('选择图片失败:', error)
  432. uni.showToast({
  433. title: '选择图片失败',
  434. icon: 'none'
  435. })
  436. }
  437. })
  438. },
  439. async uploadImageToOSS(filePath) {
  440. try {
  441. // 使用项目中的OSS上传工具
  442. const url = await OSS.ossUpload(filePath)
  443. return url
  444. } catch (error) {
  445. console.error('OSS上传失败:', error)
  446. throw error
  447. }
  448. },
  449. removeReasonImg(idx) {
  450. this.reasonImages.splice(idx, 1)
  451. },
  452. toggleReason(idx) {
  453. const val = this.reasonOptions[idx].reason.toString()
  454. const i = this.reasonChecked.indexOf(val)
  455. if (i > -1) {
  456. this.reasonChecked.splice(i, 1)
  457. } else {
  458. this.reasonChecked.push(val)
  459. }
  460. this.reasonChecked = [...this.reasonChecked]
  461. console.log('[toggleReason] reasonChecked:', this.reasonChecked)
  462. },
  463. saveReason() {
  464. if (this.currentReasonItem) {
  465. console.log('this.currentReasonItem', this.currentReasonItem)
  466. this.currentReasonItem.images = [...this.reasonImages]
  467. this.currentReasonItem.testingInstructions = this.reasonChecked.join(',')
  468. this.updateInspectData()
  469. }
  470. this.closeReasonPopup()
  471. },
  472. updateInspectData() {
  473. if (!this.inspectData || !this.currentReasonItem) return
  474. // 获取选中的理由ID(假设理由选项的索引就是ID)
  475. const selectedReasonIds = []
  476. this.reasonChecked.forEach((checked, index) => {
  477. if (checked) {
  478. selectedReasonIds.push(this.reasonOptions[index].reason.toString())
  479. }
  480. })
  481. // 将理由ID用逗号分割保存
  482. const testingInstructions = selectedReasonIds.join(',')
  483. // 将图片URL用逗号分割保存
  484. const testingImages = this.reasonImages.join(',')
  485. // 根据当前选择的商品类型,找到对应的inspectData项进行更新
  486. if (this.isQualifiedItem(this.currentReasonItem)) {
  487. this.updateQualifiedItemInspectData(testingInstructions, testingImages)
  488. } else if (this.isUnqualifiedItem(this.currentReasonItem)) {
  489. this.updateUnqualifiedItemInspectData(testingInstructions, testingImages)
  490. } else if (this.isUnrecyclableItem(this.currentReasonItem)) {
  491. this.updateUnrecyclableItemInspectData(testingInstructions, testingImages)
  492. }
  493. console.log('[updateInspectData] after update', JSON.stringify(this.inspectData, null, 2))
  494. },
  495. isQualifiedItem(item) {
  496. return this.qualifiedList.some(qualified => qualified.shopId === item.shopId)
  497. },
  498. isUnqualifiedItem(item) {
  499. return this.unqualifiedGroups.some(group =>
  500. group.items.some(unqualified => unqualified.id === item.id)
  501. )
  502. },
  503. isUnrecyclableItem(item) {
  504. return this.unrecyclableList.some(unrecyclable => unrecyclable.id === item.id)
  505. },
  506. updateQualifiedItemInspectData(testingInstructions, testingImages) {
  507. const inspectItem = this.inspectData["list"].find(item => item.id == this.currentReasonItem.id)
  508. if (inspectItem && inspectItem.commonOrderList) {
  509. // 为合格的商品更新所有状态为0的项
  510. inspectItem.commonOrderList.forEach(commonItem => {
  511. if (commonItem.testingStatus === 0) {
  512. commonItem.testingInstructions = testingInstructions
  513. commonItem.testingImages = testingImages
  514. }
  515. })
  516. }
  517. },
  518. updateUnqualifiedItemInspectData(testingInstructions, testingImages) {
  519. // 对于不合格商品,需要根据具体的commonOrderList项ID来更新
  520. this.unqualifiedGroups.forEach(group => {
  521. const targetItem = group.items.find(item => item.id === this.currentReasonItem.id)
  522. if (targetItem) {
  523. // 找到对应的inspectData项
  524. const inspectItem = this.inspectData["list"].find(item => item.id == group.id)
  525. if (inspectItem && inspectItem.commonOrderList) {
  526. // 根据不合格项的ID找到对应的commonOrderList项
  527. const commonItem = inspectItem.commonOrderList.find(common => common.id === targetItem.id)
  528. if (commonItem) {
  529. commonItem.testingInstructions = testingInstructions
  530. commonItem.testingImages = testingImages
  531. }
  532. }
  533. }
  534. })
  535. },
  536. updateUnrecyclableItemInspectData(testingInstructions, testingImages) {
  537. const inspectItem = this.inspectData["list"].find(item => item.id == this.currentReasonItem.id)
  538. if (inspectItem && inspectItem.commonOrderList) {
  539. // 为不可回收的商品更新所有状态为2的项
  540. inspectItem.commonOrderList.forEach(commonItem => {
  541. if (commonItem.testingStatus === 2) {
  542. commonItem.testingInstructions = testingInstructions
  543. commonItem.testingImages = testingImages
  544. }
  545. })
  546. }
  547. },
  548. lockScroll() {
  549. // 禁用页面滚动
  550. this.isPopupOpen = true
  551. },
  552. unlockScroll() {
  553. // 恢复页面滚动
  554. this.isPopupOpen = false
  555. },
  556. async onRefresh() {
  557. await this.refreshData && this.refreshData()
  558. },
  559. refreshData() {
  560. // 可根据实际需求刷新质检结果数据
  561. // 例如重新请求接口或重置数据
  562. },
  563. getItemBrand(id) {
  564. if (this.order && this.order.commonOrderList) {
  565. const orderItem = this.order.commonOrderList.find(item => item.id == id)
  566. return orderItem ? (orderItem.pinName || '') : ''
  567. }
  568. return ''
  569. },
  570. parseTestingInstructions() {
  571. return []
  572. },
  573. hasSelectedReason(item) {
  574. // console.log('item', item)
  575. // 检查该商品是否已选择理由或上传图片
  576. return (item.images && item.images.length > 0)
  577. }
  578. }
  579. }
  580. </script>
  581. <style lang="scss" scoped>
  582. .inspect-result-container {
  583. min-height: 100vh;
  584. background: #f8f8f8;
  585. display: flex;
  586. flex-direction: column;
  587. &.popup-open {
  588. overflow: hidden;
  589. position: fixed;
  590. width: 100%;
  591. height: 100vh;
  592. }
  593. }
  594. .nav-bar {
  595. display: flex;
  596. align-items: center;
  597. height: calc(150rpx + var(--status-bar-height));
  598. padding: 0 32rpx;
  599. padding-top: var(--status-bar-height);
  600. background: #fff;
  601. position: fixed;
  602. top: 0;
  603. left: 0;
  604. right: 0;
  605. z-index: 999;
  606. box-sizing: border-box;
  607. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
  608. .back {
  609. padding: 20rpx;
  610. margin-left: -20rpx;
  611. }
  612. .nav-title {
  613. flex: 1;
  614. text-align: center;
  615. font-size: 32rpx;
  616. font-weight: 500;
  617. color: #222;
  618. }
  619. .nav-icons {
  620. display: flex;
  621. align-items: center;
  622. gap: 12px;
  623. }
  624. }
  625. .main-content {
  626. margin-top: calc(200rpx + var(--status-bar-height));
  627. display: flex;
  628. flex-direction: column;
  629. background: none;
  630. padding-bottom: 120px;
  631. }
  632. .result-card {
  633. background: #fff;
  634. border-radius: 24px;
  635. box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  636. margin: 0 24px 24px 24px;
  637. padding: 24px 24px 0 24px;
  638. }
  639. .card-title {
  640. font-size: 16px;
  641. font-weight: bold;
  642. color: #222;
  643. margin-bottom: 18px;
  644. }
  645. .card-title-row {
  646. display: flex;
  647. align-items: center;
  648. justify-content: space-between;
  649. margin-bottom: 18px;
  650. }
  651. .status-tag {
  652. background: #fff7e6;
  653. color: #ffb400;
  654. font-size: 12px;
  655. border-radius: 12px;
  656. padding: 2px 14px;
  657. font-weight: 400;
  658. height: 22px;
  659. display: flex;
  660. align-items: center;
  661. }
  662. .result-row,
  663. .result-group {
  664. margin-bottom: 18px;
  665. }
  666. .row-main {
  667. display: flex;
  668. align-items: center;
  669. .goods-name-section {
  670. display: flex;
  671. flex-direction: column;
  672. margin-right: 8px;
  673. .goods-name {
  674. font-size: 14px;
  675. font-weight: bold;
  676. color: #222;
  677. line-height: 1.2;
  678. }
  679. .goods-brand {
  680. font-size: 11px;
  681. color: #999;
  682. font-weight: normal;
  683. line-height: 1.2;
  684. margin-top: 2px;
  685. }
  686. }
  687. .row-name {
  688. font-size: 14px;
  689. font-weight: bold;
  690. color: #222;
  691. margin-right: 8px;
  692. }
  693. .row-count {
  694. font-size: 13px;
  695. color: #888;
  696. margin-right: 8px;
  697. }
  698. .row-total {
  699. font-size: 14px;
  700. color: #222;
  701. font-weight: bold;
  702. margin-left: auto;
  703. }
  704. }
  705. .row-reason {
  706. display: flex;
  707. align-items: center;
  708. margin-top: 8px;
  709. .reason-label {
  710. font-size: 13px;
  711. color: #bbb;
  712. min-width: 80px;
  713. }
  714. .reason-input {
  715. flex: 1;
  716. height: 36px;
  717. border-radius: 12px;
  718. background: #f6f6f6;
  719. border: none;
  720. font-size: 14px;
  721. color: #222;
  722. padding-left: 12px;
  723. margin-left: 8px;
  724. }
  725. .reason-select {
  726. flex: 1;
  727. display: flex;
  728. align-items: center;
  729. height: 36px;
  730. border-radius: 12px;
  731. background: #f6f6f6;
  732. font-size: 14px;
  733. color: #bbb;
  734. padding-left: 12px;
  735. margin-left: 8px;
  736. justify-content: flex-end;
  737. }
  738. .reason-placeholder {
  739. color: #bbb;
  740. font-size: 14px;
  741. &.selected {
  742. color: #52c41a;
  743. font-weight: 500;
  744. }
  745. }
  746. }
  747. .info-card {
  748. background: #fff;
  749. border-radius: 24px;
  750. box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  751. margin: 0 24px 24px 24px;
  752. padding: 24px 24px 0 24px;
  753. }
  754. .info-row {
  755. display: flex;
  756. align-items: center;
  757. margin-bottom: 16px;
  758. .info-label {
  759. font-size: 13px;
  760. color: #bbb;
  761. min-width: 80px;
  762. }
  763. .info-value {
  764. font-size: 13px;
  765. color: #222;
  766. margin-left: 8px;
  767. }
  768. .copy-btn {
  769. color: #ffb400;
  770. margin-left: 8px;
  771. }
  772. }
  773. .footer-btns {
  774. position: fixed;
  775. left: 0;
  776. right: 0;
  777. bottom: 0;
  778. background: #fff;
  779. display: flex;
  780. gap: 16px;
  781. padding: 12px 16px 24px 16px;
  782. z-index: 101;
  783. .btn-outline {
  784. flex: 1;
  785. height: 40px;
  786. border-radius: 16px;
  787. border: 1px solid #ffe09a;
  788. color: #ffb400;
  789. background: #fff0d2;
  790. font-size: 15px;
  791. font-weight: 500;
  792. box-shadow: none;
  793. padding: 0 18px;
  794. }
  795. .btn-main {
  796. flex: 1;
  797. height: 40px;
  798. border-radius: 16px;
  799. background: linear-gradient(90deg, #ffd01e 0%, #ffac04 100%);
  800. color: #fff;
  801. border: none;
  802. font-size: 15px;
  803. font-weight: 500;
  804. box-shadow: none;
  805. padding: 0 18px;
  806. }
  807. }
  808. .reason-popup-wrapper {
  809. z-index: 10000 !important;
  810. }
  811. .reason-popup-wrapper .uni-popup__wrapper {
  812. z-index: 10000 !important;
  813. }
  814. .reason-popup {
  815. background: #fff;
  816. border-radius: 24px 24px 0 0;
  817. padding: 0;
  818. height: 75vh;
  819. position: relative;
  820. z-index: 9999;
  821. .popup-header {
  822. display: flex;
  823. align-items: center;
  824. justify-content: center;
  825. height: 60px;
  826. border-bottom: 1px solid #f0f0f0;
  827. position: relative;
  828. .popup-close {
  829. position: absolute;
  830. left: 20px;
  831. color: #666;
  832. font-size: 16px;
  833. }
  834. .popup-title {
  835. font-size: 18px;
  836. font-weight: 600;
  837. color: #222;
  838. }
  839. }
  840. .popup-content {
  841. height: calc(75vh - 60px - 82px);
  842. overflow-y: auto;
  843. }
  844. .popup-section {
  845. padding: 0 20px 24px 20px;
  846. &:first-child {
  847. padding-top: 24px;
  848. }
  849. .section-label {
  850. font-size: 16px;
  851. color: #222;
  852. margin-bottom: 16px;
  853. display: block;
  854. font-weight: 500;
  855. }
  856. .img-list {
  857. display: flex;
  858. gap: 12px;
  859. margin-bottom: 32px;
  860. .img-item {
  861. width: 80px;
  862. height: 80px;
  863. border-radius: 12px;
  864. background: #f8f8f8;
  865. position: relative;
  866. .img {
  867. width: 100%;
  868. height: 100%;
  869. border-radius: 12px;
  870. object-fit: cover;
  871. }
  872. .img-del {
  873. position: absolute;
  874. top: -6px;
  875. right: -6px;
  876. width: 24px;
  877. height: 24px;
  878. background: rgba(0, 0, 0, 0.6);
  879. color: #fff;
  880. border-radius: 50%;
  881. text-align: center;
  882. line-height: 24px;
  883. font-size: 16px;
  884. font-weight: bold;
  885. }
  886. &.add {
  887. display: flex;
  888. align-items: center;
  889. justify-content: center;
  890. background: #f8f8f8;
  891. border: 2px dashed #ddd;
  892. color: #bbb;
  893. }
  894. }
  895. }
  896. .reason-row {
  897. display: flex;
  898. align-items: center;
  899. padding: 16px 0;
  900. border-bottom: 1px solid #f0f0f0;
  901. &:last-child {
  902. border-bottom: none;
  903. }
  904. .checkbox {
  905. width: 20px;
  906. height: 20px;
  907. border-radius: 4px;
  908. border: 2px solid #ddd;
  909. margin-right: 12px;
  910. background: #fff;
  911. position: relative;
  912. &.checked {
  913. border-color: #ffb400;
  914. background: #ffb400;
  915. &::after {
  916. content: '✓';
  917. position: absolute;
  918. top: 50%;
  919. left: 50%;
  920. transform: translate(-50%, -50%);
  921. color: #fff;
  922. font-size: 12px;
  923. font-weight: bold;
  924. }
  925. }
  926. }
  927. .reason-text {
  928. font-size: 16px;
  929. color: #222;
  930. line-height: 1.4;
  931. }
  932. }
  933. }
  934. .popup-save-btn {
  935. position: fixed;
  936. bottom: 34px;
  937. left: 20px;
  938. right: 20px;
  939. height: 48px;
  940. border-radius: 24px;
  941. background: linear-gradient(90deg, #ffd01e 0%, #ffac04 100%);
  942. color: #fff;
  943. font-size: 18px;
  944. font-weight: 600;
  945. border: none;
  946. display: flex;
  947. align-items: center;
  948. justify-content: center;
  949. box-shadow: 0 4px 12px rgba(255, 172, 4, 0.3);
  950. }
  951. }
  952. </style>