commonProductList.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view>
  3. <view v-for="(item, index) in list" :key="index">
  4. <view class="product-card">
  5. <view class="card-header">
  6. <text class="product-name">{{ item.productName || '物品' + (index + 1) }}</text>
  7. <text class="product-price">{{ item.productCode || '-' }}</text>
  8. </view>
  9. <view class="card-body">
  10. <view class="info-row" v-for="(field, idx) in tableField" :key="idx">
  11. <text class="info-label">{{ field.label }}:</text>
  12. <text class="info-value">{{ formatValue(item, field) }} {{ field.unit || '' }}</text>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <u-empty v-if="!list || list.length === 0" text="暂无物品清单" marginTop="100"></u-empty>
  18. </view>
  19. </template>
  20. <script>
  21. import {transactionMethodsOp,shippingModeOp,shippingModePurchaseOp, pricingWayList, levelList, quoteTypeOp} from '@/enum/dict.js'
  22. import { mapGetters } from 'vuex'
  23. export default {
  24. name: 'common-product-list',
  25. computed: {
  26. ...mapGetters(['getDictValue'])
  27. },
  28. props: {
  29. list: {
  30. type: Array,
  31. default: () => []
  32. },
  33. tableField: {
  34. type: Array,
  35. default: () => [
  36. { label: '类型', field: 'productCategoryName' },
  37. { label: '批次号', field: 'batchNo' },
  38. // { label: '名称', field: 'productName' },
  39. { label: '计价方式', field: 'pricingWay', type: 'pricingWay' },
  40. // { label: '编码', field: 'productCode' },
  41. { label: '规格', field: 'specification' },
  42. { label: '牌号', field: 'brandNo' },
  43. { label: '客户代号', field: 'customerMark' },
  44. { label: '包装规格', field: 'packingSpecification' },
  45. { label: '机型', field: 'modelKey' },
  46. { label: '颜色', field: 'colorKey' },
  47. { label: '价格类型', field: 'goodsPriceType', type: 'dict', dictName: '商品价格类型' },
  48. { label: '单价', field: 'singlePrice' },
  49. { label: '折让单价', field: 'discountSinglePrice' },
  50. { label: '单重', field: 'singleWeight' },
  51. { label: '总重', field: 'totalWeight' },
  52. { label: '增重重量', field: 'increaseTotalWeight' },
  53. { label: '数量', field: 'saleCount' },
  54. { label: '计量数量', field: 'totalCount' },
  55. { label: '税率', field: 'taxRate', unit: '%'},
  56. { label: '合计', field: 'totalPrice' },
  57. { label: '折让合计金额', field: 'discountTotalPrice' },
  58. ]
  59. }
  60. },
  61. data() {
  62. return {
  63. pricingWayList
  64. }
  65. },
  66. methods: {
  67. // 格式化字段值
  68. formatValue(item, field) {
  69. let value = item[field.field]
  70. // 数量字段显示单位
  71. if (field.field === 'saleCount') {
  72. const unit = item.saleUnit || ''
  73. return value ? value + (unit ? ' ' + unit : '') : '-'
  74. }
  75. // 计量数量字段显示单位
  76. if (field.field === 'totalCount') {
  77. const unit = item.measuringUnit || ''
  78. return value ? value + (unit ? ' ' + unit : '') : '-'
  79. }
  80. // 单重字段显示单位
  81. if (field.field === 'singleWeight') {
  82. const unit = item.weightUnit || ''
  83. return value ? value + (unit ? ' ' + unit : '') : '-'
  84. }
  85. // 总重字段显示单位
  86. if (field.field === 'totalWeight') {
  87. const unit = item.weightUnit || ''
  88. return value ? value + (unit ? ' ' + unit : '') : '-'
  89. }
  90. // 增重重量字段显示单位
  91. if (field.field === 'increaseTotalWeight') {
  92. const unit = item.weightUnit || ''
  93. return value ? value + (unit ? ' ' + unit : '') : '-'
  94. }
  95. // 计价方式特殊处理
  96. if (field.type === 'pricingWay') {
  97. const found = this.pricingWayList.find(p => p.id === value)
  98. return found ? found.name : '-'
  99. }
  100. // 收货状态特殊处理
  101. if (field.field === 'isException') {
  102. return value == 1 ? '有异常' : '无异常'
  103. }
  104. if (field.field === 'packingQuantity') {
  105. const unit = item.packingUnit || ''
  106. return value ? value + (unit ? ' ' + unit : '') : '-'
  107. }
  108. if (field.field === 'type') {
  109. return value == 1 ? '已回收' : '未回收'
  110. }
  111. // 字典类型处理
  112. if (field.type === 'dict') {
  113. return this.getDictValue(field.dictName, value) || '-'
  114. }
  115. return value || '-'
  116. }
  117. }
  118. }
  119. </script>
  120. <style scoped>
  121. .product-card {
  122. margin: 20rpx;
  123. padding: 20rpx;
  124. background: #fff;
  125. border-radius: 12rpx;
  126. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  127. }
  128. .card-header {
  129. display: flex;
  130. justify-content: space-between;
  131. align-items: center;
  132. padding-bottom: 16rpx;
  133. border-bottom: 1rpx solid #eee;
  134. margin-bottom: 16rpx;
  135. }
  136. .product-name {
  137. font-size: 28rpx;
  138. font-weight: bold;
  139. color: #333;
  140. }
  141. .product-price {
  142. font-size: 26rpx;
  143. /* color: #157a2c; */
  144. /* font-weight: bold; */
  145. }
  146. .card-body {
  147. display: flex;
  148. flex-wrap: wrap;
  149. }
  150. .info-row {
  151. width: 50%;
  152. display: flex;
  153. padding: 8rpx 0;
  154. box-sizing: border-box;
  155. }
  156. .info-label {
  157. color: #666;
  158. font-size: 26rpx;
  159. flex-shrink: 0;
  160. }
  161. .info-value {
  162. color: #333;
  163. font-size: 26rpx;
  164. overflow: hidden;
  165. text-overflow: ellipsis;
  166. white-space: nowrap;
  167. }
  168. </style>