Incubator.vue 13 KB

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