Incubator.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  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. <view class="card_tab_freezer" v-if="detailsFlag && isCoolerInfo.isCoolerReleaseCold">
  11. <view class="select_freezer">
  12. <view style="display: flex;align-items: center;margin-right: 10rpx;">
  13. <view class="title_num blue_color">总数:{{Total}}</view>
  14. <view class="title_num green_color">已选:{{selectedList.length}}</view>
  15. </view>
  16. <view style="display: flex;align-items: center;">
  17. <view class="select_title blue_color" @click="checkAll">全选</view>
  18. <view class="select_title orange_color" @click="Inverse">反选</view>
  19. </view>
  20. </view>
  21. </view>
  22. </u-sticky>
  23. <view class="card_incubator" v-if="orderList.length > 0">
  24. <view :class="iceColdFlag ? 'item_bator' : 'item_bator_cold'" v-for="(item,index) in orderList" :key="index"
  25. @click.stop="selectIncubator(item)">
  26. <view style="display: flex;align-items: center;">
  27. <span class="iconfont icon-incubator" :class="iceColdFlag ? 'imagebwx' : 'imagebwx_cold'"></span>
  28. <view>{{item.name}}</view>
  29. </view>
  30. <view class="floe_card" v-if="item.ice_raft.length > 0 && iceColdFlag">
  31. <view class="card_ice_list">
  32. <view class="card_ice_item" v-for="(item1,index) in item.ice_raft">
  33. <view style="display: flex;align-items: center;height: 60rpx;">
  34. <span class="iconfont icon-bingpaiguanli icon_ice"></span>
  35. <view style="margin-left: 5rpx;">
  36. <view class="ice_title">{{item1.label}}</view>
  37. <view class="ice_code">{{item1.code}}</view>
  38. </view>
  39. </view>
  40. <view style="display: flex;align-items: center;">
  41. <view class="title_cryophilic" style="margin-right: 5rpx;">
  42. 释冷温度:<span v-if="item1.iceRaftRecord">{{item1.iceRaftRecord.suitableForCold || 0}}℃
  43. </span></view>
  44. <view class="title_cryophilic">释冷时间:<span>≥{{item1.suitableForColdTime}}min</span>
  45. </view>
  46. </view>
  47. <view class="title_cryophilic" v-if="item1.iceRaftRecord">
  48. 出库时间:{{item1.iceRaftRecord.outStorageTime}}</view>
  49. </view>
  50. <view class="card_ice_item" style="border: unset;flex: 1;padding: 0rpx;margin: 0rpx;"></view>
  51. </view>
  52. <view class="card_ice_list"></view>
  53. </view>
  54. <view class="btn_printil markd10" v-if="item.ice_raft.length > 0 && getIceState(item.ice_raft)"
  55. @click.stop="endCooling(item.ice_raft)">
  56. <u-button size="small" type="warning" text="结束释冷"></u-button>
  57. </view>
  58. <view class="position-triangle" v-if="item.whetherFlag">
  59. <span>已选</span>
  60. </view>
  61. </view>
  62. <view style="width: 100%;">
  63. <u-loadmore lineColor="#ffffff" :status="loadStatus" :key="Math.random()" />
  64. </view>
  65. </view>
  66. <view style="margin-top: 20%;" v-else>
  67. <u-empty mode="list" text="暂无保温箱"></u-empty>
  68. </view>
  69. <view style="width: 100%;height: 120rpx;" class="env_padding" v-if="detailsFlag"></view>
  70. <view class="card_btn_freezer" v-if="detailsFlag && isCoolerInfo.isCoolerReleaseCold">
  71. <u-button style="margin-bottom: 20rpx;" type="primary" @click="coolingRelease">保温箱预冷</u-button>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. export default {
  77. data() {
  78. return {
  79. keyword: '',
  80. currentPage: 1,
  81. pageSize: 15,
  82. loadingMore: true,
  83. loadStatus: 'loadmore', //loading 、nomore
  84. incubatorValue: '',
  85. orderList: [],
  86. detailsFlag: false,
  87. showFlag: true,
  88. // 是否释冷
  89. iceColdFlag: true,
  90. Total: 0,
  91. selectedList: [],
  92. isCoolerInfo: {},
  93. searchShow: true,
  94. }
  95. },
  96. onReachBottom() {
  97. if (!this.loadingMore) {
  98. this.getIncubator()
  99. }
  100. },
  101. onLoad(option) {
  102. if (option.detailsFlag) {
  103. this.detailsFlag = true
  104. }
  105. },
  106. mounted() {
  107. var userInfo = this.$cache.getCache('userInfo')
  108. this.isCoolerInfo = userInfo.dept
  109. this.getIncubator()
  110. },
  111. methods: {
  112. // 搜索
  113. searchChange(value) {
  114. var that = this
  115. if (that.searchShow) {
  116. that.searchShow = false
  117. const timer = setTimeout(function() {
  118. clearTimeout(timer);
  119. that.currentPage = 1
  120. that.orderList = []
  121. that.loadingMore = true
  122. that.getIncubator()
  123. }, 300);
  124. }
  125. },
  126. // 获取保温箱
  127. getIncubator() {
  128. this.loadStatus = 'loading'
  129. this.loadingMore = true
  130. this.$api.get('/api/cooler-box', {
  131. page: this.currentPage,
  132. pageSize: this.pageSize,
  133. name: this.keyword,
  134. status: '2',
  135. }).then(res => {
  136. if (res.code == 200) {
  137. const data = res.data.list
  138. this.Total = res.data.count
  139. if (this.loadingMore == true && data) {
  140. this.orderList = this.orderList.concat(data);
  141. // console.log(this.orderList, 245)
  142. }
  143. this.getRecord()
  144. if (data.length < this.pageSize) {
  145. this.loadingMore = true
  146. this.loading = '没有更多了'
  147. this.loadStatus = 'nomore'
  148. } else {
  149. this.loading = '加载中'
  150. this.loadStatus = 'loading'
  151. this.loadingMore = false
  152. this.currentPage++
  153. }
  154. }
  155. this.searchShow = true
  156. })
  157. },
  158. // 保温箱预冷
  159. coolingRelease() {
  160. console.log(this.selectedList, 24)
  161. if (this.selectedList.length > 0) {
  162. let arrID = this.selectedList.map(item => item.toString())
  163. this.$api.post('/api/cooler-box/coolerboxstarttime', {
  164. id: arrID,
  165. }).then(res => {
  166. if (res.code == 200) {
  167. uni.$u.toast('操作成功')
  168. }
  169. })
  170. } else {
  171. uni.$u.toast('请先选择释冷冰排')
  172. }
  173. },
  174. // 判断冰排是否选择
  175. getRecord() {
  176. this.orderList.forEach(item => {
  177. let index = this.selectedList.findIndex((event) => event === item.id);
  178. if (index !== -1) {
  179. item.whetherFlag = true
  180. } else {
  181. item.whetherFlag = false
  182. }
  183. })
  184. this.$forceUpdate()
  185. },
  186. // 全选
  187. checkAll() {
  188. this.selectedList = []
  189. for (let i = 0; i < this.orderList.length; i++) {
  190. this.$set(this.orderList[i], 'whetherFlag', true)
  191. }
  192. this.orderList.forEach(item => {
  193. if (item.whetherFlag) {
  194. this.selectedList.push(item.id)
  195. }
  196. })
  197. this.getRecord()
  198. },
  199. // 反选
  200. Inverse() {
  201. this.selectedList = []
  202. for (let i = 0; i < this.orderList.length; i++) {
  203. let flag = this.orderList[i].whetherFlag;
  204. this.$set(this.orderList[i], 'whetherFlag', !flag)
  205. }
  206. this.orderList.forEach(item => {
  207. if (item.whetherFlag) {
  208. this.selectedList.push(item.id)
  209. }
  210. })
  211. this.getRecord()
  212. },
  213. // 结束释冷
  214. endCooling(event) {
  215. let list = event.filter(item => item.iceRaftRecord.isSuitableForCold == 0);
  216. const idsString = list.map(item => item.iceRaftRecordId);
  217. this.$api.post('/api/ice-raft-record/end-for-cold', {
  218. iceRaftRecordId: idsString,
  219. }).then(res => {
  220. if (res.code == 200) {
  221. uni.$u.toast('操作成功')
  222. this.currentPage = 1
  223. this.orderList = []
  224. this.getIncubator()
  225. }
  226. })
  227. },
  228. // 选择保温箱
  229. selectIncubator(value) {
  230. if (this.detailsFlag) {
  231. // console.log('详情')
  232. let index = this.selectedList.findIndex((item) => item === value.id);
  233. // 如果有就替换,没有就添加
  234. if (index !== -1) {
  235. this.selectedList.splice(index, 1);
  236. } else {
  237. this.selectedList.push(value.id);
  238. }
  239. if (this.isCoolerInfo.isCoolerReleaseCold) {
  240. this.getRecord()
  241. }
  242. } else {
  243. uni.setStorageSync('incubatorValue', value)
  244. uni.navigateBack({
  245. delta: 1
  246. });
  247. }
  248. },
  249. // 保温箱下所有冰排释冷状态
  250. getIceState(event) {
  251. let arrList = event
  252. let bol = true
  253. // isSuitableForCold 0 未释冷 1 已释冷
  254. for (let i = 0; i < arrList.length; i++) {
  255. if (arrList[i].iceRaftRecord.isSuitableForCold == 1) {
  256. bol = false
  257. break //减少循环次数
  258. }
  259. }
  260. return bol
  261. },
  262. navbarHeight() {
  263. let systemInfo = uni.getSystemInfoSync();
  264. /* (750 / systemInfo.windowWidth) */
  265. /* 在uview navBar组件中有一个默认高度,当这个默认高度加上状态栏高度后就是吸顶的位置,由于这两者相加是px,所以最后还需要转为rpx */
  266. let topHeight = 0
  267. // #ifdef APP-PLUS
  268. topHeight = 44 + systemInfo.statusBarHeight;
  269. // #endif
  270. // #ifdef MP
  271. let height = systemInfo.platform == 'ios' ? 44 : 48;
  272. topHeight = height + systemInfo.statusBarHeight
  273. // #endif
  274. /* 最后一步将px转为rpx */
  275. return topHeight * (750 / systemInfo.windowWidth) / 2
  276. },
  277. },
  278. }
  279. </script>
  280. <style lang="scss" scoped>
  281. .card_incubator {
  282. display: flex;
  283. flex-direction: column;
  284. margin-top: 10rpx;
  285. }
  286. .search_card {
  287. background-color: #fff;
  288. padding: 20rpx;
  289. }
  290. .card_tab_freezer {
  291. display: flex;
  292. align-items: center;
  293. justify-content: space-between;
  294. padding: 0rpx 20rpx 20rpx 20rpx;
  295. background-color: #fff;
  296. }
  297. .card_subsection {
  298. width: 50%;
  299. }
  300. .select_freezer {
  301. display: flex;
  302. align-items: flex-end;
  303. // flex-direction: column;
  304. }
  305. .title_num {
  306. font-size: 26rpx;
  307. margin-left: 10rpx;
  308. }
  309. .select_title {
  310. font-size: 30rpx;
  311. margin-left: 15rpx;
  312. }
  313. .blue_color {
  314. color: #2979ff;
  315. }
  316. .green_color {
  317. color: #19be6b;
  318. }
  319. .orange_color {
  320. color: #ff9900;
  321. }
  322. .item_bator {
  323. position: relative;
  324. display: flex;
  325. flex-direction: column;
  326. background-color: #fff;
  327. border-radius: 10rpx;
  328. padding: 15rpx;
  329. margin: 10rpx 20rpx;
  330. overflow: hidden;
  331. }
  332. .item_bator_cold {
  333. position: relative;
  334. display: flex;
  335. flex-direction: column;
  336. background-color: #fff;
  337. border-radius: 10rpx;
  338. padding: 30rpx;
  339. margin: 10rpx 20rpx;
  340. overflow: hidden;
  341. }
  342. .position-triangle {
  343. position: absolute;
  344. bottom: 0;
  345. right: 0;
  346. overflow: hidden;
  347. height: 35px;
  348. width: 35px;
  349. }
  350. .position-triangle span {
  351. position: absolute;
  352. font-size: 20rpx;
  353. bottom: 8rpx;
  354. right: 3rpx;
  355. z-index: 1;
  356. color: #fff;
  357. transform: rotate(-45deg);
  358. }
  359. .position-triangle::after {
  360. content: "";
  361. font-size: 20rpx;
  362. position: absolute;
  363. width: 70px;
  364. height: 70px;
  365. background-color: #19be6b;
  366. transform: rotate(45deg);
  367. transform-origin: center;
  368. top: 50%;
  369. }
  370. .imagebwx {
  371. color: #2b85e4;
  372. font-size: 60rpx;
  373. margin-right: 20rpx;
  374. }
  375. .imagebwx_cold {
  376. color: #2b85e4;
  377. font-size: 70rpx;
  378. margin-right: 20rpx;
  379. }
  380. .floe_card {
  381. padding: 15rpx 0rpx;
  382. display: flex;
  383. flex-direction: column;
  384. }
  385. .card_ice_list {
  386. display: flex;
  387. flex-direction: row;
  388. flex-wrap: wrap;
  389. justify-content: space-between;
  390. }
  391. .card_ice_item {
  392. flex: none;
  393. margin: 0rpx 10rpx;
  394. margin-bottom: 10rpx;
  395. padding: 6rpx 10rpx;
  396. border-radius: 6rpx;
  397. border: 1rpx solid #e7e6e4;
  398. }
  399. .ice_title {
  400. font-size: 28rpx;
  401. }
  402. .icon_ice {
  403. font-size: 44rpx;
  404. color: #19be6b;
  405. margin-right: 5rpx;
  406. }
  407. .ice_code {
  408. font-size: 24rpx;
  409. }
  410. .title_cryophilic {
  411. margin-top: 5rpx;
  412. font-size: 23rpx;
  413. span {
  414. color: #19be6b;
  415. }
  416. }
  417. .card_btn_freezer {
  418. position: fixed;
  419. z-index: 2;
  420. bottom: 0;
  421. left: 0;
  422. right: 0;
  423. padding: 20rpx 30rpx 20rpx 30rpx;
  424. background-color: #fff;
  425. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  426. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  427. border-top: 1rpx solid #E4E7ED;
  428. }
  429. .env_padding {
  430. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  431. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  432. }
  433. </style>