Incubator.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. <template>
  2. <!-- 选择保温箱、 -->
  3. <view>
  4. <u-navbar title="保温箱管理" 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 @click="endOfUse">
  22. <u-button size="small" type="error" text="结束使用"></u-button>
  23. </view>
  24. </view>
  25. </u-sticky>
  26. <view class="card_incubator" v-if="orderList.length > 0">
  27. <view :class="iceColdFlag ? 'item_bator' : 'item_bator_cold'" v-for="(item,index) in orderList" :key="index"
  28. @click.stop="selectIncubator(item)">
  29. <view class="space_between">
  30. <view style="display: flex;align-items: center;margin-bottom: 10rpx;">
  31. <span class="iconfont icon-incubator"
  32. :class="iceColdFlag ? 'imagebwx' : 'imagebwx_cold'"></span>
  33. <view>{{item.name}}</view>
  34. </view>
  35. <view class="card_precooling" :style="{color: filterColor(item.useStatus)}">
  36. {{matchingType(item.useStatus)}}
  37. </view>
  38. </view>
  39. <view v-if="isCoolerInfo.isCoolerReleaseCold && item.useStatus == 1 || item.useStatus == 3">
  40. <view class="card_precool" v-if="item.cold_temperatures">预冷温度(℃): {{item.cold_temperatures}}</view>
  41. <view class="card_precool" v-if="item.cold_spots">预冷地点: {{item.cold_spots}}</view>
  42. <view style="display: flex;align-items: center;">
  43. <view class="card_precool" v-if="item.for_cold_cooler_time">预冷要求:
  44. <span>{{item.for_cold_cooler_time}}h</span>
  45. </view>
  46. <view class="card_precool" v-if="item.cooler_box_record.for_cold_duration">预冷时间:
  47. <span>{{item.cooler_box_record.for_cold_duration}}</span>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="floe_card" v-if="item.ice_raft.length > 0 && iceColdFlag">
  52. <view class="card_ice_list">
  53. <view class="card_ice_item" v-for="(item1,index) in item.ice_raft">
  54. <view style="display: flex;align-items: center;height: 60rpx;">
  55. <span class="iconfont icon-bingpaiguanli icon_ice"></span>
  56. <view style="margin-left: 5rpx;">
  57. <view class="ice_code">{{item1.code}}</view>
  58. <view class="ice_title">{{item1.label}}</view>
  59. </view>
  60. </view>
  61. <view style="display: flex;flex-direction: column;">
  62. <view class="title_cryophilic" style="margin-right: 5rpx;">
  63. 释冷温度:<span v-if="item1.iceRaftRecord">{{item1.iceRaftRecord.suitableForCold || 0}}℃
  64. </span></view>
  65. <view class="title_cryophilic">
  66. 冷冻时间:<span>{{formatMinutes(item1.iceRaftRecord.freezeDuration)}}</span>
  67. </view>
  68. </view>
  69. <view class="title_cryophilic" v-if="item1.iceRaftRecord">
  70. 出库时间:{{item1.iceRaftRecord.outStorageTime}}</view>
  71. </view>
  72. <view class="card_ice_item" style="border: unset;"></view>
  73. </view>
  74. <view class="card_ice_list"></view>
  75. </view>
  76. <view class="btn_printil markd10" v-if="detailsFlag">
  77. <view style="flex: 1;margin-right: 10rpx;"
  78. v-if="item.ice_raft.length > 0 && getIceState(item.ice_raft)"
  79. @click.stop="endCooling(item.ice_raft)">
  80. <u-button size="small" type="warning" text="结束释冷"></u-button>
  81. </view>
  82. <view style="flex: 1;" v-if="item.useStatus && item.useStatus == 2" @click.stop="endOfUseil(item)">
  83. <u-button size="small" type="error" text="结束使用"></u-button>
  84. </view>
  85. </view>
  86. <view class="position-triangle" v-if="item.whetherFlag">
  87. <span>已选</span>
  88. </view>
  89. <!-- <view class="position-inuse center_in" v-if="item.monitorStatus == 1">
  90. <span>使用中</span>
  91. </view> -->
  92. </view>
  93. <view style="width: 100%;">
  94. <u-loadmore lineColor="#ffffff" :status="loadStatus" :key="Math.random()" />
  95. </view>
  96. </view>
  97. <view style="margin-top: 20%;" v-else>
  98. <u-empty mode="list" text="暂无保温箱"></u-empty>
  99. </view>
  100. <view style="width: 100%;height: 120rpx;" class="env_padding" v-if="detailsFlag"></view>
  101. <view class="card_btn_freezer" v-if="detailsFlag && isCoolerInfo.isCoolerReleaseCold">
  102. <u-button style="margin-bottom: 20rpx;" type="primary" @click="coolingRelease">保温箱预冷</u-button>
  103. </view>
  104. </view>
  105. </template>
  106. <script>
  107. export default {
  108. data() {
  109. return {
  110. keyword: '',
  111. currentPage: 1,
  112. pageSize: 15,
  113. loadingMore: true,
  114. loadStatus: 'loadmore', //loading 、nomore
  115. incubatorValue: '',
  116. orderList: [],
  117. detailsFlag: false,
  118. showFlag: true,
  119. // 是否释冷
  120. iceColdFlag: true,
  121. Total: 0,
  122. selectedList: [],
  123. isCoolerInfo: {},
  124. searchShow: true,
  125. usageStatus: [{
  126. bgcolor: '#2979ff',
  127. label: '预冷中',
  128. value: 1,
  129. }, {
  130. bgcolor: '#67C23A',
  131. label: '使用中',
  132. value: 2,
  133. }, {
  134. bgcolor: '#67C23A',
  135. label: '预冷完成',
  136. value: 3,
  137. }]
  138. }
  139. },
  140. onReachBottom() {
  141. if (!this.loadingMore) {
  142. this.getIncubator()
  143. }
  144. },
  145. onLoad(option) {
  146. if (option.detailsFlag) {
  147. this.detailsFlag = true
  148. }
  149. },
  150. mounted() {
  151. var userInfo = this.$cache.getCache('userInfo')
  152. this.isCoolerInfo = userInfo.dept
  153. this.getIncubator()
  154. },
  155. methods: {
  156. // 搜索
  157. searchChange(value) {
  158. var that = this
  159. if (that.searchShow) {
  160. that.searchShow = false
  161. const timer = setTimeout(function() {
  162. clearTimeout(timer);
  163. that.currentPage = 1
  164. that.orderList = []
  165. that.loadingMore = true
  166. that.getIncubator()
  167. }, 300);
  168. }
  169. },
  170. // 获取保温箱
  171. getIncubator() {
  172. this.loadStatus = 'loading'
  173. this.loadingMore = true
  174. this.$api.get('/api/cooler-box', {
  175. page: this.currentPage,
  176. pageSize: this.pageSize,
  177. name: this.keyword,
  178. status: '2',
  179. }).then(res => {
  180. if (res.code == 200) {
  181. const data = res.data.list
  182. this.Total = res.data.count
  183. if (this.loadingMore == true && data) {
  184. this.orderList = this.orderList.concat(data);
  185. }
  186. this.getRecord()
  187. if (data.length < this.pageSize) {
  188. this.loadingMore = true
  189. this.loading = '没有更多了'
  190. this.loadStatus = 'nomore'
  191. } else {
  192. this.loading = '加载中'
  193. this.loadStatus = 'loading'
  194. this.loadingMore = false
  195. this.currentPage++
  196. }
  197. }
  198. this.searchShow = true
  199. })
  200. },
  201. // 保温箱预冷
  202. coolingRelease() {
  203. if (this.selectedList.length > 0) {
  204. uni.showLoading({
  205. mask: true
  206. });
  207. let arrID = this.selectedList.map(item => item.toString())
  208. this.$api.post('/api/cooler-box/coolerboxstarttime', {
  209. id: arrID,
  210. }).then(res => {
  211. if (res.code == 200) {
  212. uni.$u.toast('操作成功')
  213. this.searchChange()
  214. this.orderList.forEach(item => {
  215. item.whetherFlag = false
  216. })
  217. this.selectedList = []
  218. } else {
  219. uni.$u.toast(res.msg)
  220. }
  221. uni.hideLoading();
  222. }).catch(() => {
  223. uni.hideLoading();
  224. })
  225. } else {
  226. uni.$u.toast('请先选择保温箱')
  227. }
  228. },
  229. // 结束使用
  230. endOfUse() {
  231. if (this.selectedList.length > 0) {
  232. uni.showLoading({
  233. mask: true
  234. });
  235. let arrID = this.selectedList.map(item => item.toString())
  236. this.$api.put('/api/cooler-box/coolerBoxEndUse', {
  237. id: arrID,
  238. }).then(res => {
  239. if (res.code == 200) {
  240. uni.$u.toast('操作成功')
  241. this.currentPage = 1
  242. this.orderList = []
  243. this.loadingMore = true
  244. this.getIncubator()
  245. } else {
  246. uni.$u.toast(res.msg || '操作成功')
  247. }
  248. uni.hideLoading();
  249. }).catch(() => {
  250. uni.hideLoading();
  251. })
  252. } else {
  253. uni.$u.toast('请先选择保温箱')
  254. }
  255. },
  256. // 结束使用单个
  257. endOfUseil(event) {
  258. let incubatorId = String(event.id)
  259. uni.showLoading({
  260. mask: true
  261. });
  262. this.$api.put('/api/cooler-box/coolerBoxEndUse', {
  263. id: [incubatorId],
  264. }).then(res => {
  265. if (res.code == 200) {
  266. uni.$u.toast('操作成功')
  267. this.currentPage = 1
  268. this.orderList = []
  269. this.loadingMore = true
  270. this.getIncubator()
  271. }
  272. uni.hideLoading();
  273. }).catch(() => {
  274. uni.hideLoading();
  275. })
  276. },
  277. // 判断冰排是否选择
  278. getRecord() {
  279. this.orderList.forEach(item => {
  280. let index = this.selectedList.findIndex((event) => event === item.id);
  281. if (index !== -1) {
  282. item.whetherFlag = true
  283. } else {
  284. item.whetherFlag = false
  285. }
  286. })
  287. this.$forceUpdate()
  288. },
  289. // 全选
  290. checkAll() {
  291. this.selectedList = []
  292. for (let i = 0; i < this.orderList.length; i++) {
  293. this.$set(this.orderList[i], 'whetherFlag', true)
  294. }
  295. this.orderList.forEach(item => {
  296. if (item.whetherFlag) {
  297. this.selectedList.push(item.id)
  298. }
  299. })
  300. this.getRecord()
  301. },
  302. // 反选
  303. Inverse() {
  304. this.selectedList = []
  305. for (let i = 0; i < this.orderList.length; i++) {
  306. let flag = this.orderList[i].whetherFlag;
  307. this.$set(this.orderList[i], 'whetherFlag', !flag)
  308. }
  309. this.orderList.forEach(item => {
  310. if (item.whetherFlag) {
  311. this.selectedList.push(item.id)
  312. }
  313. })
  314. this.getRecord()
  315. },
  316. // 结束释冷
  317. endCooling(event) {
  318. let list = event.filter(item => item.iceRaftRecord.isSuitableForCold == 0);
  319. const idsString = list.map(item => item.iceRaftRecordId);
  320. this.$api.post('/api/ice-raft-record/end-for-cold', {
  321. iceRaftRecordId: idsString,
  322. }).then(res => {
  323. if (res.code == 200) {
  324. uni.$u.toast('操作成功')
  325. this.currentPage = 1
  326. this.orderList = []
  327. this.getIncubator()
  328. }
  329. })
  330. },
  331. // 选择保温箱
  332. selectIncubator(value) {
  333. if (this.detailsFlag) {
  334. // console.log('详情')
  335. let index = this.selectedList.findIndex((item) => item === value.id);
  336. // 如果有就替换,没有就添加
  337. if (index !== -1) {
  338. this.selectedList.splice(index, 1);
  339. } else {
  340. this.selectedList.push(value.id);
  341. }
  342. if (this.isCoolerInfo.isCoolerReleaseCold) {
  343. this.getRecord()
  344. }
  345. } else {
  346. uni.setStorageSync('incubatorValue', value)
  347. uni.navigateBack({
  348. delta: 1
  349. });
  350. }
  351. },
  352. // 保温箱下所有冰排释冷状态
  353. getIceState(event) {
  354. let arrList = event
  355. let bol = false
  356. // isSuitableForCold 0 未释冷 1 已释冷
  357. for (let i = 0; i < arrList.length; i++) {
  358. if (arrList[i].iceRaftRecord.isSuitableForCold === 0) {
  359. bol = true
  360. break //减少循环次数
  361. }
  362. }
  363. return bol
  364. },
  365. // 总分钟格式化
  366. formatMinutes(totalMinutes) {
  367. if (totalMinutes) {
  368. const hours = Math.floor(totalMinutes / 60); // 计算小时
  369. const minutes = totalMinutes % 60; // 计算分钟(余数)
  370. return `${hours}h${minutes}m`;
  371. } else {
  372. return ''
  373. }
  374. },
  375. matchingType(type) {
  376. let list = this.usageStatus
  377. let name = ''
  378. if (list) {
  379. list.forEach(item => {
  380. if (type === item.value) {
  381. name = item.label
  382. }
  383. })
  384. }
  385. return name
  386. },
  387. // tag颜色获取
  388. filterColor(type) {
  389. let list = this.usageStatus
  390. let color = ''
  391. if (list) {
  392. list.forEach(item => {
  393. if (type === item.value) {
  394. color = item.bgcolor
  395. }
  396. })
  397. }
  398. return color
  399. },
  400. navbarHeight() {
  401. let systemInfo = uni.getSystemInfoSync();
  402. /* (750 / systemInfo.windowWidth) */
  403. /* 在uview navBar组件中有一个默认高度,当这个默认高度加上状态栏高度后就是吸顶的位置,由于这两者相加是px,所以最后还需要转为rpx */
  404. let topHeight = 0
  405. // #ifdef APP-PLUS
  406. topHeight = 44 + systemInfo.statusBarHeight;
  407. // #endif
  408. // #ifdef MP
  409. let height = systemInfo.platform == 'ios' ? 44 : 48;
  410. topHeight = height + systemInfo.statusBarHeight
  411. // #endif
  412. /* 最后一步将px转为rpx */
  413. return topHeight * (750 / systemInfo.windowWidth) / 2
  414. },
  415. },
  416. }
  417. </script>
  418. <style lang="scss" scoped>
  419. .card_incubator {
  420. display: flex;
  421. flex-direction: column;
  422. margin-top: 10rpx;
  423. }
  424. .search_card {
  425. background-color: #fff;
  426. padding: 20rpx;
  427. }
  428. .card_tab_freezer {
  429. display: flex;
  430. align-items: center;
  431. justify-content: space-between;
  432. padding: 0rpx 20rpx 20rpx 20rpx;
  433. background-color: #fff;
  434. }
  435. .card_subsection {
  436. width: 50%;
  437. }
  438. .select_freezer {
  439. display: flex;
  440. align-items: flex-end;
  441. // flex-direction: column;
  442. }
  443. .title_num {
  444. font-size: 26rpx;
  445. margin-left: 10rpx;
  446. }
  447. .select_title {
  448. font-size: 30rpx;
  449. margin-left: 15rpx;
  450. }
  451. .blue_color {
  452. color: #2979ff;
  453. }
  454. .green_color {
  455. color: #19be6b;
  456. }
  457. .orange_color {
  458. color: #ff9900;
  459. }
  460. .item_bator {
  461. position: relative;
  462. display: flex;
  463. flex-direction: column;
  464. background-color: #fff;
  465. border-radius: 10rpx;
  466. padding: 15rpx;
  467. margin: 10rpx 20rpx;
  468. overflow: hidden;
  469. }
  470. .item_bator_cold {
  471. position: relative;
  472. display: flex;
  473. flex-direction: column;
  474. background-color: #fff;
  475. border-radius: 10rpx;
  476. padding: 30rpx;
  477. margin: 10rpx 20rpx;
  478. overflow: hidden;
  479. }
  480. .position-triangle {
  481. position: absolute;
  482. bottom: 0;
  483. right: 0;
  484. overflow: hidden;
  485. height: 35px;
  486. width: 35px;
  487. }
  488. .position-triangle span {
  489. position: absolute;
  490. font-size: 20rpx;
  491. bottom: 8rpx;
  492. right: 3rpx;
  493. z-index: 1;
  494. color: #fff;
  495. transform: rotate(-45deg);
  496. }
  497. .position-triangle::after {
  498. content: "";
  499. font-size: 20rpx;
  500. position: absolute;
  501. width: 70px;
  502. height: 70px;
  503. background-color: #19be6b;
  504. transform: rotate(45deg);
  505. transform-origin: center;
  506. top: 50%;
  507. }
  508. .position-inuse {
  509. position: absolute;
  510. bottom: 0;
  511. top: 10rpx;
  512. right: 15rpx;
  513. width: 100rpx;
  514. height: 40rpx;
  515. font-size: 24rpx;
  516. border-radius: 6rpx;
  517. color: #E4E7ED;
  518. background-color: #19be6b;
  519. }
  520. .imagebwx {
  521. color: #2b85e4;
  522. font-size: 60rpx;
  523. margin-right: 20rpx;
  524. }
  525. .imagebwx_cold {
  526. color: #2b85e4;
  527. font-size: 70rpx;
  528. margin-right: 20rpx;
  529. }
  530. .floe_card {
  531. // padding: 15rpx 0rpx;
  532. display: flex;
  533. flex-direction: column;
  534. }
  535. .card_ice_list {
  536. display: flex;
  537. flex-direction: row;
  538. flex-wrap: wrap;
  539. // justify-content: space-around;
  540. justify-content: space-between;
  541. }
  542. .btn_printil {
  543. display: flex;
  544. align-items: center;
  545. }
  546. .card_ice_item {
  547. flex: none;
  548. width: calc(50% - 20rpx);
  549. padding: 10rpx 7rpx;
  550. margin-bottom: 10rpx;
  551. border-radius: 6rpx;
  552. border: 1rpx solid #e7e6e4;
  553. }
  554. .ice_title {
  555. font-size: 20rpx;
  556. }
  557. .icon_ice {
  558. font-size: 44rpx;
  559. color: #19be6b;
  560. margin-right: 5rpx;
  561. }
  562. .ice_code {
  563. font-size: 24rpx;
  564. font-weight: bold;
  565. }
  566. .title_cryophilic {
  567. margin-top: 5rpx;
  568. font-size: 23rpx;
  569. span {
  570. color: #19be6b;
  571. }
  572. }
  573. .card_btn_freezer {
  574. position: fixed;
  575. z-index: 2;
  576. bottom: 0;
  577. left: 0;
  578. right: 0;
  579. padding: 20rpx 30rpx 20rpx 30rpx;
  580. background-color: #fff;
  581. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  582. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  583. border-top: 1rpx solid #E4E7ED;
  584. }
  585. .env_padding {
  586. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  587. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  588. }
  589. .card_precooling {
  590. color: #19be6b;
  591. font-size: 30rpx;
  592. flex: none;
  593. margin-right: 10rpx;
  594. }
  595. .card_precool {
  596. font-size: 28rpx;
  597. margin-right: 10px;
  598. span {
  599. color: #19be6b;
  600. }
  601. }
  602. </style>