index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <div
  3. @click="toSet"
  4. class="components-product-item"
  5. :class="{
  6. 'pitem-full': data.cargoCapacity == data.qty,
  7. 'pitem-close': data.cargoState != 1,
  8. 'pitem-fault': data.faultState == 1,
  9. 'pitem-active': isActive,
  10. 'pitem-main': data.state == 21
  11. }"
  12. >
  13. <div :style="'height: ' + rate + '%'" class="pitem-bg"></div>
  14. <div class="pitem-inner">
  15. <div class="kitbox ">
  16. <div class="box-flex-1">{{ wayerNo }}号位</div>
  17. <div>{{ data.qty }}/{{ data.cargoCapacity }}</div>
  18. </div>
  19. <template v-if="data.shelfStatus == 1">
  20. <div class="ellipsis tc pt12">{{ data.drugName }}</div>
  21. <div class="ellipsis tc pt10">{{ data.specif }}</div>
  22. </template>
  23. <div v-else class="ellipsis tc pt12 ">未设药品</div>
  24. </div>
  25. <div class="tag" v-if="data.state == 21">主</div>
  26. <div class="tag" v-else-if="data.state == 20">副</div>
  27. <img class="gouxuan" src="@/assets/images/gouxuan.png" alt="" />
  28. </div>
  29. </template>
  30. <script>
  31. export default {
  32. props: ['data', 'index', 'bussuness', 'isView', 'old'], //bussuness quick快速补货 isView
  33. data() {
  34. return {
  35. isActive: false
  36. }
  37. },
  38. computed: {
  39. wayerNo() {
  40. if (this.data.state == 21) {
  41. var arr = this.data.merge.split(',')
  42. return arr[0] + '~' + arr[arr.length - 1]
  43. }
  44. return this.data.wayerNo
  45. },
  46. rate() {
  47. var { data } = this
  48. return ((data.qty || 0) / (data.cargoCapacity || 5)) * 100
  49. }
  50. },
  51. watch: {
  52. 'data.isActive': {
  53. handler(n) {
  54. this.isActive = n
  55. },
  56. deep: true
  57. }
  58. },
  59. created() {
  60. this.isActive = this.data.isActive
  61. },
  62. methods: {
  63. toSet() {
  64. if (this.isView) {
  65. return
  66. }
  67. if (this.bussuness == 'quick') {
  68. this.isActive = !this.isActive
  69. this.$emit('onChange', this.isActive)
  70. return
  71. }
  72. if (this.data.state == 20) {
  73. this.$toast('不能操作副通道,如要修改请修改它的主通道')
  74. return
  75. }
  76. if (this.data.shelfStatus != 1) {
  77. if (this.old) {
  78. this.gotoUrl('/oldDrugList', {
  79. trackId: this.data.id,
  80. deviceId: this.data.idDevice,
  81. cargoCapacity: this.data.cargoCapacity
  82. })
  83. } else {
  84. this.gotoUrl('/drugList', {
  85. trackId: this.data.id,
  86. deviceId: this.data.idDevice,
  87. cargoCapacity: this.data.cargoCapacity
  88. })
  89. }
  90. } else {
  91. this.gotoUrl('./productDetail', {
  92. id: this.data.id
  93. })
  94. }
  95. }
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .components-product-item {
  101. overflow: hidden;
  102. width: 100px;
  103. height: 80px;
  104. background: rgb(238, 238, 238);
  105. border-radius: 10px;
  106. margin-left: 10px;
  107. padding: 5px;
  108. font-size: 14px;
  109. position: relative;
  110. &.pitem-full {
  111. color: #fff;
  112. }
  113. &:first-child {
  114. margin-left: 0;
  115. }
  116. .pitem-inner {
  117. position: relative;
  118. z-index: 1;
  119. background: transparent;
  120. line-height: 1.2;
  121. }
  122. .pitem-bg {
  123. background: #17b3ec;
  124. position: absolute;
  125. z-index: 0;
  126. width: 100%;
  127. bottom: 0;
  128. left: 0;
  129. border-bottom-left-radius: 10px;
  130. border-bottom-right-radius: 10px;
  131. &.orange {
  132. background: #ff9526;
  133. }
  134. &.red {
  135. background: #ff5e6c;
  136. }
  137. }
  138. .tag {
  139. color: red;
  140. position: absolute;
  141. right: 2px;
  142. bottom: 2px;
  143. font-size: 12px;
  144. }
  145. &.pitem-close {
  146. background-color: #ff9526;
  147. color: #fff;
  148. .pitem-bg {
  149. display: none;
  150. }
  151. }
  152. &.pitem-fault {
  153. background-color: #ff5e6c;
  154. color: #fff;
  155. .pitem-bg {
  156. display: none;
  157. }
  158. }
  159. .gouxuan {
  160. position: absolute;
  161. right: 0;
  162. bottom: 0;
  163. width: 20px;
  164. display: none;
  165. }
  166. &.pitem-active {
  167. border: 1px solid red;
  168. .gouxuan {
  169. display: block;
  170. }
  171. }
  172. &.pitem-main {
  173. width: 280px !important;
  174. }
  175. }
  176. </style>