priceTable.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <div class="farm-table">
  3. <div class="new-wrap">
  4. <div class="new-title">
  5. <div class="title-1"><div class="table-name">类型</div></div>
  6. <div class="title-2"><div class="table-name">名称</div></div>
  7. <div class="title-3"><div class="table-name">品牌</div></div>
  8. <div class="title-4"><div class="table-name">单价</div></div>
  9. <div class="title-5"><div class="table-name">用量</div></div>
  10. <div class="title-6"><div class="table-name">总价</div></div>
  11. </div>
  12. <div
  13. class="new-table-wrap"
  14. >
  15. <div
  16. class="new-prescription"
  17. v-for="(subP, subI) in prescriptionData.pesticideFertilizerList"
  18. :key="subI"
  19. >
  20. <div class="new-table">
  21. <div class="line-l">
  22. <div class="line-1 title-1">{{ subP.typeName }}</div>
  23. <div class="line-2">{{ subP.name || subP.defaultName || subP.pesticideFertilizerName }}</div>
  24. <div class="title-3">{{ subP.brand }}</div>
  25. <div class="title-4">{{ subP.price }}</div>
  26. <div class="title-5">{{ subP.dosage }}</div>
  27. <div class="title-6">{{ getTotal(subP) }}元</div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. <slot name="bottomContent"></slot>
  34. </div>
  35. </template>
  36. <script setup>
  37. const props = defineProps({
  38. prescriptionData: {
  39. default: () => ({}),
  40. },
  41. // 面积(亩数),用于计算总价:单价 * 用量 * 面积
  42. area: {
  43. type: [Number, String],
  44. default: null,
  45. },
  46. });
  47. // 计算单个药肥的总价:单价 * 用量 * 面积
  48. const getTotal = (item) => {
  49. const price = Number(item?.price ?? 0);
  50. const dosage = Number(item?.dosage ?? 0);
  51. const area = props.area != null ? Number(props.area) : Number(item?.area ?? 0);
  52. // 如果有现成的 total 字段且无法计算,则退回使用 total
  53. if (!price || !dosage || !area) {
  54. return item?.total ?? "--";
  55. }
  56. return (price * dosage * area).toFixed(2);
  57. };
  58. </script>
  59. <style lang="scss" scoped>
  60. .box-wrap {
  61. background: #fff;
  62. padding: 10px;
  63. border-radius: 8px;
  64. }
  65. .card-title {
  66. font-size: 16px;
  67. font-weight: bold;
  68. color: #000;
  69. display: flex;
  70. align-items: center;
  71. .type-tag {
  72. margin-left: 5px;
  73. font-size: 12px;
  74. color: #000000;
  75. padding: 0 10px;
  76. background: rgba(119, 119, 119, 0.1);
  77. border-radius: 20px;
  78. font-weight: normal;
  79. height: 26px;
  80. line-height: 26px;
  81. }
  82. }
  83. .farm-table {
  84. .table-item {
  85. padding: 10px 0 12px 0;
  86. }
  87. .form-item {
  88. display: flex;
  89. align-items: center;
  90. font-size: 14px;
  91. color: #767676;
  92. height: 24px;
  93. .item-name {
  94. width: 80px;
  95. color: rgba(0, 0, 0, 0.2);
  96. }
  97. }
  98. }
  99. .new-wrap {
  100. border-radius: 5px;
  101. text-align: center;
  102. border: 1px solid rgba(225, 225, 225, 0.5);
  103. .new-title {
  104. background: rgba(241, 241, 241, 0.4);
  105. border-radius: 5px 5px 0 0;
  106. border-bottom: 1px solid rgba(225, 225, 225, 0.5);
  107. display: flex;
  108. color: #767676;
  109. // justify-content: space-around;
  110. padding: 5px 6px;
  111. font-size: 12px;
  112. .table-name {
  113. width: 24px;
  114. font-size: 12px;
  115. margin: 0 auto;
  116. }
  117. }
  118. .title-1 {
  119. width: 40px;
  120. }
  121. .title-2 {
  122. flex: 1;
  123. }
  124. .title-3 {
  125. width: 52px;
  126. }
  127. .title-4 {
  128. width: 56px;
  129. }
  130. .title-5 {
  131. width: 52px;
  132. }
  133. .title-6 {
  134. width: 52px;
  135. }
  136. .new-table-wrap {
  137. padding: 5px;
  138. .new-prescription {
  139. .new-table {
  140. display: flex;
  141. align-items: center;
  142. background: #fff;
  143. border-radius: 5px;
  144. color: rgba(0, 0, 0, 0.6);
  145. font-size: 11px;
  146. min-height: 45px;
  147. .line-l {
  148. display: flex;
  149. align-items: center;
  150. flex: 1;
  151. .line-2 {
  152. flex: 1;
  153. padding: 0 2px;
  154. }
  155. }
  156. .line-r {
  157. &.has-border {
  158. border-left: 1px solid rgba(225, 225, 225, 0.8);
  159. }
  160. .line-3 {
  161. display: flex;
  162. align-items: center;
  163. }
  164. .sub-line {
  165. padding: 10px 0;
  166. }
  167. .line-4 {
  168. display: flex;
  169. align-items: center;
  170. border-top: 1px solid rgba(225, 225, 225, 0.8);
  171. }
  172. .execute-line {
  173. border-right: 1px solid rgba(225, 225, 225, 0.8);
  174. }
  175. }
  176. }
  177. .note-text {
  178. margin: 8px 0 4px 0;
  179. color: rgba(0, 0, 0, 0.4);
  180. background: #fff;
  181. padding: 6px 8px;
  182. border-radius: 5px;
  183. text-align: left;
  184. font-size: 11px;
  185. }
  186. }
  187. .new-prescription + .new-prescription {
  188. padding-top: 8px;
  189. }
  190. }
  191. .new-table-wrap + .new-table-wrap {
  192. border-top: 1px solid rgba(0, 0, 0, 0.08);
  193. }
  194. }
  195. </style>