Incubator.vue 13 KB

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