detail.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <script setup>
  2. import { ref } from 'vue'
  3. import { onLoad, onShow } from '@dcloudio/uni-app'
  4. import { getInventory, getInventoryRelated } from '@/api/db'
  5. import { inventoryStatusLabel, dash, formatWeight } from '@/utils/dbLabels'
  6. import { PAGE_PATHS } from '@/config/api'
  7. const id = ref('')
  8. const detail = ref(null)
  9. const related = ref({ plan: null, weighing: null })
  10. const goBack = () => {
  11. uni.navigateBack({
  12. fail: () => uni.navigateTo({ url: PAGE_PATHS.dbInventoryList })
  13. })
  14. }
  15. const load = async () => {
  16. if (!id.value) return
  17. try {
  18. detail.value = await getInventory(id.value)
  19. related.value = await getInventoryRelated(id.value)
  20. } catch (e) {
  21. uni.showToast({ title: e.message || '加载失败', icon: 'none' })
  22. }
  23. }
  24. const openWeighing = () => {
  25. if (!related.value?.weighing?.id) {
  26. uni.showToast({ title: '暂无关联地磅单', icon: 'none' })
  27. return
  28. }
  29. uni.navigateTo({
  30. url: `${PAGE_PATHS.dbWeighingDetail}?id=${related.value.weighing.id}`
  31. })
  32. }
  33. const openPlan = () => {
  34. if (!related.value?.plan?.id) {
  35. uni.showToast({ title: '暂无关联计划', icon: 'none' })
  36. return
  37. }
  38. uni.navigateTo({
  39. url: `${PAGE_PATHS.dbPlansDetail}?id=${related.value.plan.id}`
  40. })
  41. }
  42. onLoad((q) => {
  43. id.value = q?.id || ''
  44. })
  45. onShow(() => load())
  46. </script>
  47. <template>
  48. <view class="mp-page mp-page--sub">
  49. <view class="mp-header mp-header--db">
  50. <text class="mp-subpage-back" @click="goBack">← 返回</text>
  51. <text class="mp-header__title" style="margin-top: 16rpx">出入库详情</text>
  52. </view>
  53. <view v-if="detail" class="mp-detail-hero">
  54. <view class="mp-detail-hero__top">
  55. <view>
  56. <text class="mp-detail-hero__title">{{ dash(detail.batchNo || detail.id) }}</text>
  57. <text class="mp-detail-hero__sub">{{ dash(detail.product) }} · {{ dash(detail.businessType) }}</text>
  58. </view>
  59. <text class="mp-tag" :class="'mp-tag--' + inventoryStatusLabel(detail.status).tag">
  60. {{ inventoryStatusLabel(detail.status).text }}
  61. </text>
  62. </view>
  63. <view class="mp-detail-hero__meta">
  64. <text class="mp-detail-hero__chip">{{ dash(detail.vehicleNo) }}</text>
  65. <text class="mp-detail-hero__chip">{{ formatWeight(detail.quantity) }}</text>
  66. </view>
  67. </view>
  68. <view class="mp-block">
  69. <text class="mp-block__title">基本信息</text>
  70. <view class="mp-block__panel">
  71. <view class="mp-kv"><text class="mp-kv__label">日期</text><text class="mp-kv__value">{{ dash(detail?.date) }}</text></view>
  72. <view class="mp-kv"><text class="mp-kv__label">往来单位</text><text class="mp-kv__value">{{ dash(detail?.partnerCompany) }}</text></view>
  73. <view class="mp-kv"><text class="mp-kv__label">规格</text><text class="mp-kv__value">{{ dash(detail?.specification) }}</text></view>
  74. <view class="mp-kv"><text class="mp-kv__label">计划号</text><text class="mp-kv__value">{{ dash(detail?.planNo) }}</text></view>
  75. <view class="mp-kv"><text class="mp-kv__label">备注</text><text class="mp-kv__value">{{ dash(detail?.remarks) }}</text></view>
  76. </view>
  77. </view>
  78. <view class="mp-block">
  79. <text class="mp-block__title">过磅数据</text>
  80. <view class="mp-block__panel">
  81. <view class="mp-kv"><text class="mp-kv__label">毛重</text><text class="mp-kv__value">{{ formatWeight(detail?.grossWeight) }}</text></view>
  82. <view class="mp-kv"><text class="mp-kv__label">皮重</text><text class="mp-kv__value">{{ formatWeight(detail?.tareWeight) }}</text></view>
  83. <view class="mp-kv"><text class="mp-kv__label">净重</text><text class="mp-kv__value">{{ formatWeight(detail?.netWeight) }}</text></view>
  84. </view>
  85. </view>
  86. <view v-if="detail?.siteFeedbackRemark || detail?.siteFeedbackImages?.length" class="mp-block">
  87. <text class="mp-block__title">现场反馈</text>
  88. <view class="mp-block__panel" style="padding: 28rpx">
  89. <text style="font-size: 26rpx">{{ dash(detail.siteFeedbackRemark) }}</text>
  90. </view>
  91. </view>
  92. <view class="mp-section">
  93. <view class="mp-list">
  94. <view class="mp-card" @click="openWeighing">
  95. <view class="mp-card__head">
  96. <text class="mp-card__title">关联地磅单</text>
  97. <text class="mp-tag mp-tag--info">{{ related.weighing ? '查看' : '无' }}</text>
  98. </view>
  99. </view>
  100. <view class="mp-card" @click="openPlan">
  101. <view class="mp-card__head">
  102. <text class="mp-card__title">关联计划</text>
  103. <text class="mp-tag mp-tag--info">{{ related.plan ? '查看' : '无' }}</text>
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. </template>