Incubator.vue 14 KB

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