Incubator.vue 13 KB

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