Incubator.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <!-- 选择保温箱、 -->
  3. <view>
  4. <u-navbar autoBack placeholder></u-navbar>
  5. <u-sticky :customNavHeight="navbarHeight()">
  6. <view class="search_card">
  7. <u-search :showAction="false" v-model="keyword" @change="searchChange"
  8. placeholder="输入关键字快速查找"></u-search>
  9. </view>
  10. </u-sticky>
  11. <view class="card_incubator" v-if="orderList.length > 0">
  12. <view :class="iceColdFlag ? 'item_bator' : 'item_bator_cold'" v-for="(item,index) in orderList" :key="index"
  13. @click.stop="selectIncubator(item)">
  14. <view style="display: flex;align-items: center;">
  15. <span class="iconfont icon-incubator" :class="iceColdFlag ? 'imagebwx' : 'imagebwx_cold'"></span>
  16. <view>{{item.name}}</view>
  17. </view>
  18. <view class="floe_card" v-if="item.ice_raft.length > 0 && iceColdFlag">
  19. <view class="card_ice_list">
  20. <view class="card_ice_item" v-for="(item1,index) in item.ice_raft">
  21. <view style="display: flex;align-items: center;height: 60rpx;">
  22. <span class="iconfont icon-bingpaiguanli icon_ice"></span>
  23. <view style="margin-left: 5rpx;">
  24. <view class="ice_title">{{item1.label}}</view>
  25. <view class="ice_code">{{item1.code}}</view>
  26. </view>
  27. </view>
  28. <view style="display: flex;align-items: center;">
  29. <view class="title_cryophilic" style="margin-right: 5rpx;">
  30. 适冷温度:<span v-if="item1.iceRaftRecord">{{item1.iceRaftRecord.suitableForCold || 0}}℃
  31. </span></view>
  32. <view class="title_cryophilic">适冷时间:<span>≥{{item1.suitableForColdTime}}min</span>
  33. </view>
  34. </view>
  35. <view class="title_cryophilic" v-if="item1.iceRaftRecord">
  36. 出库时间:{{item1.iceRaftRecord.outStorageTime}}</view>
  37. </view>
  38. <view class="card_ice_item" style="border: unset;flex: 1;padding: 0rpx;margin: 0rpx;"></view>
  39. </view>
  40. <view class="card_ice_list"></view>
  41. </view>
  42. <view class="btn_printil markd10" v-if="item.ice_raft.length > 0 && getIceState(item.ice_raft)"
  43. @click.stop="endCooling(item.ice_raft)">
  44. <u-button size="small" type="warning" text="结束适冷"></u-button>
  45. </view>
  46. </view>
  47. <view style="width: 100%;">
  48. <u-loadmore lineColor="#ffffff" :status="loadStatus" :key="Math.random()" />
  49. </view>
  50. </view>
  51. <view style="margin-top: 20%;" v-else>
  52. <u-empty mode="list" text="暂无保温箱"></u-empty>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. keyword: '',
  61. currentPage: 1,
  62. pageSize: 15,
  63. loadingMore: true,
  64. loadStatus: 'loadmore', //loading 、nomore
  65. incubatorValue: '',
  66. orderList: [],
  67. detailsFlag: false,
  68. iceData: [{
  69. label: '冰排1',
  70. code: '202409091350938276'
  71. }, {
  72. label: '冰排1',
  73. code: '202409091350938276'
  74. }, {
  75. label: '冰排1',
  76. code: '202409091350938276'
  77. }],
  78. showFlag: true,
  79. // 是否释冷
  80. iceColdFlag: true,
  81. }
  82. },
  83. onReachBottom() {
  84. if (!this.loadingMore) {
  85. this.getIncubator()
  86. }
  87. },
  88. onLoad(option) {
  89. if (option.detailsFlag) {
  90. this.detailsFlag = true
  91. }
  92. console.log(option, 25)
  93. },
  94. mounted() {
  95. this.getIncubator()
  96. },
  97. methods: {
  98. // 搜索
  99. searchChange(value) {
  100. this.currentPage = 1
  101. this.orderList = []
  102. this.loadingMore = true
  103. this.getIncubator()
  104. },
  105. // 获取保温箱
  106. getIncubator() {
  107. this.loadStatus = 'loading'
  108. this.loadingMore = true
  109. this.$api.get('/api/cooler-box', {
  110. page: this.currentPage,
  111. pageSize: this.pageSize,
  112. name: this.keyword,
  113. status: '2',
  114. }).then(res => {
  115. if (res.code == 200) {
  116. const data = res.data.list
  117. if (this.loadingMore == true && data) {
  118. this.orderList = this.orderList.concat(data);
  119. // console.log(this.orderList, 245)
  120. }
  121. if (data.length < this.pageSize) {
  122. this.loadingMore = true
  123. this.loading = '没有更多了'
  124. this.loadStatus = 'nomore'
  125. } else {
  126. this.loading = '加载中'
  127. this.loadStatus = 'loading'
  128. this.loadingMore = false
  129. this.currentPage++
  130. }
  131. }
  132. })
  133. },
  134. // 结束适冷
  135. endCooling(event) {
  136. let list = event.filter(item => item.iceRaftRecord.isSuitableForCold == 0);
  137. const idsString = list.map(item => item.iceRaftRecordId);
  138. this.$api.post('/api/ice-raft-record/end-for-cold', {
  139. iceRaftRecordId: idsString,
  140. }).then(res => {
  141. console.log(res, 235)
  142. if (res.code == 200) {
  143. uni.$u.toast('操作成功')
  144. this.currentPage = 1
  145. this.orderList = []
  146. this.getIncubator()
  147. }
  148. })
  149. },
  150. // 选择保温箱
  151. selectIncubator(value) {
  152. if (this.detailsFlag) {
  153. console.log('详情')
  154. } else {
  155. uni.setStorageSync('incubatorValue', value)
  156. uni.navigateBack({
  157. delta: 1
  158. });
  159. }
  160. },
  161. // 保温箱下所有冰排适冷状态
  162. getIceState(event) {
  163. let arrList = event
  164. let bol = true
  165. // isSuitableForCold 0 未适冷 1 已适冷
  166. for (let i = 0; i < arrList.length; i++) {
  167. if (arrList[i].iceRaftRecord.isSuitableForCold == 1) {
  168. bol = false
  169. break //减少循环次数
  170. }
  171. }
  172. return bol
  173. },
  174. navbarHeight() {
  175. let systemInfo = uni.getSystemInfoSync();
  176. /* (750 / systemInfo.windowWidth) */
  177. /* 在uview navBar组件中有一个默认高度,当这个默认高度加上状态栏高度后就是吸顶的位置,由于这两者相加是px,所以最后还需要转为rpx */
  178. let topHeight = 0
  179. // #ifdef APP-PLUS
  180. topHeight = 44 + systemInfo.statusBarHeight;
  181. // #endif
  182. // #ifdef MP
  183. let height = systemInfo.platform == 'ios' ? 44 : 48;
  184. topHeight = height + systemInfo.statusBarHeight
  185. // #endif
  186. /* 最后一步将px转为rpx */
  187. return topHeight * (750 / systemInfo.windowWidth) / 2
  188. },
  189. },
  190. }
  191. </script>
  192. <style lang="scss" scoped>
  193. .card_incubator {
  194. display: flex;
  195. flex-direction: column;
  196. margin-top: 10rpx;
  197. }
  198. .search_card {
  199. background-color: #fff;
  200. padding: 20rpx;
  201. }
  202. .item_bator {
  203. display: flex;
  204. flex-direction: column;
  205. background-color: #fff;
  206. border-radius: 10rpx;
  207. padding: 15rpx;
  208. margin: 10rpx 20rpx;
  209. }
  210. .item_bator_cold {
  211. display: flex;
  212. flex-direction: column;
  213. background-color: #fff;
  214. border-radius: 10rpx;
  215. padding: 30rpx;
  216. margin: 10rpx 20rpx;
  217. }
  218. .imagebwx {
  219. color: #2b85e4;
  220. font-size: 60rpx;
  221. margin-right: 20rpx;
  222. }
  223. .imagebwx_cold {
  224. color: #2b85e4;
  225. font-size: 70rpx;
  226. margin-right: 20rpx;
  227. }
  228. .floe_card {
  229. padding: 15rpx 0rpx;
  230. display: flex;
  231. flex-direction: column;
  232. }
  233. .card_ice_list {
  234. display: flex;
  235. flex-direction: row;
  236. flex-wrap: wrap;
  237. justify-content: space-between;
  238. }
  239. .card_ice_item {
  240. flex: none;
  241. margin: 0rpx 10rpx;
  242. margin-bottom: 10rpx;
  243. padding: 6rpx 10rpx;
  244. border-radius: 6rpx;
  245. border: 1rpx solid #e7e6e4;
  246. }
  247. .ice_title {
  248. font-size: 28rpx;
  249. }
  250. .icon_ice {
  251. font-size: 44rpx;
  252. color: #19be6b;
  253. margin-right: 5rpx;
  254. }
  255. .ice_code {
  256. font-size: 24rpx;
  257. }
  258. .title_cryophilic {
  259. margin-top: 5rpx;
  260. font-size: 23rpx;
  261. span {
  262. color: #19be6b;
  263. }
  264. }
  265. </style>