freezer.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. <template>
  2. <!-- 冷冻柜冰排 -->
  3. <view>
  4. <u-navbar :title="headline" 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 style="margin-left: 10rpx;" @click="sweep">
  10. <u-icon name="scan" color="#606266" size="35"></u-icon>
  11. </view>
  12. </view>
  13. <view class="card_tab_freezer">
  14. <view :style="{width:isIceInfo.isIceReleaseCold ? '70%':'100%'}">
  15. <view class="card_subsection">
  16. <view :class="item.id == current ? 'activate_subsection' : 'item_subsection'"
  17. v-for="(item,index) in iceStateList" :key="index" @click="sectionChange(item)">
  18. {{item.title}}
  19. </view>
  20. </view>
  21. </view>
  22. <view class="select_freezer" v-if="isIceInfo.isIceReleaseCold">
  23. <view style="display: flex;align-items: center;">
  24. <view class="select_title blue_color" @click="checkAll">全选</view>
  25. <view class="select_title orange_color" @click="Inverse">反选</view>
  26. </view>
  27. <view style="display: flex;align-items: center;margin-bottom: 10rpx;">
  28. <view class="title_num blue_color">总数:{{Total}}</view>
  29. <view class="title_num green_color">已选:{{selectedList.length}}</view>
  30. </view>
  31. </view>
  32. </view>
  33. </u-sticky>
  34. <view style="display: flex;flex-direction: column;" v-if="list.length > 0">
  35. <view class="card_item_iceraft" v-for="(item,index) in list" :key="index" @click="choiceIce(item)">
  36. <view class="top_title space_between">
  37. <view class="title_Icecode">编号: {{item.code}}</view>
  38. <view style="font-size: 30rpx;" :style="{color: filterColor(item.iceRaftRecord.status)}">
  39. {{matchingType(item.iceRaftRecord.status)}}
  40. </view>
  41. </view>
  42. <view class="title_itemIce">冰排备注:{{item.label}}</view>
  43. <view class="title_itemIce" v-if="item.iceRaftRecord.inStorageTime">入库时间:
  44. {{item.iceRaftRecord.inStorageTime}}
  45. </view>
  46. <view class="title_itemIce" v-if="item.iceRaftRecord.outStorageTime">出库时间:
  47. {{item.iceRaftRecord.outStorageTime}}
  48. </view>
  49. <view class="title_itemIce"
  50. v-if="item.iceRaftRecord.outStorageTime == '' && item.iceRaftRecord.iceLocker.name">所在位置:
  51. {{item.iceRaftRecord.iceLocker.name}}
  52. </view>
  53. <view class="title_itemIce"
  54. v-else-if="item.iceRaftRecord.outStorageTime != '' && item.iceRaftRecord.coolerBox.name">所在位置:
  55. {{item.iceRaftRecord.coolerBox.name}}
  56. </view>
  57. <view class="title_itemIce" v-if="item.iceRaftRecord.status != ''">冷冻要求:
  58. <span>{{getFreeze(item.iceRaftRecord.freezeClaim)}}</span>
  59. </view>
  60. <view style="display: flex;align-items: center;">
  61. <view class="title_itemIce" style="margin-right: 10rpx;" v-if="item.iceRaftRecord.status != ''">
  62. 冷冻时间:
  63. <span>{{formatMinutes(item.iceRaftRecord.freezeDuration)}}</span>
  64. </view>
  65. <view class="title_itemIce" v-if="item.iceRaftRecord.status != ''">释冷时间:
  66. <span>{{formatMinutes(item.iceRaftRecord.forColdTimeActual)}}</span>
  67. </view>
  68. </view>
  69. <view class="position-triangle" v-if="item.whetherFlag">
  70. <span>已选</span>
  71. </view>
  72. </view>
  73. <view style="width: 100%;">
  74. <u-loadmore lineColor="#ffffff" :status="loadStatus" :key="Math.random()" />
  75. </view>
  76. </view>
  77. <view style="margin-top: 20%;" v-else>
  78. <u-empty mode="list" text="暂无冰排信息"></u-empty>
  79. </view>
  80. <view style="width: 100%;height: 120rpx;" class="env_padding" v-if="isIceInfo.isIceReleaseCold"></view>
  81. <view class="card_btn_freezer" v-if="isIceInfo.isIceReleaseCold">
  82. <u-button style="margin-bottom: 20rpx;" type="primary" @click="coolingRelease">出库释冷</u-button>
  83. </view>
  84. </view>
  85. </template>
  86. <script>
  87. export default {
  88. data() {
  89. return {
  90. headline: '',
  91. list: [],
  92. typeList: [{
  93. bgcolor: '#2979ff',
  94. label: '冷冻中',
  95. value: '1',
  96. }, {
  97. bgcolor: '#19be6b',
  98. label: '待使用',
  99. value: '2',
  100. }, {
  101. bgcolor: '#ff9900',
  102. label: '释冷中',
  103. value: '5',
  104. }, {
  105. bgcolor: '#67C23A',
  106. label: '释冷完成',
  107. value: '6',
  108. }],
  109. iceState: null,
  110. iceStateList: [],
  111. icelist: [{
  112. id: 0,
  113. title: '全部',
  114. }, {
  115. id: 1,
  116. title: '冷冻中',
  117. }, {
  118. id: 2,
  119. title: '待使用',
  120. }],
  121. icelistil: [{
  122. id: 0,
  123. title: '全部',
  124. }, {
  125. id: 1,
  126. title: '冷冻中',
  127. }, {
  128. id: 2,
  129. title: '待使用',
  130. }, {
  131. id: 5,
  132. title: '释冷中',
  133. }, {
  134. id: 6,
  135. title: '释冷完成',
  136. }],
  137. current: 0,
  138. PageIndex: 1,
  139. PageSize: 15,
  140. loadStatus: 'loadmore', //loading 、nomore
  141. loadingMore: true,
  142. keyword: '',
  143. freezerId: null,
  144. Total: 0,
  145. selectedNum: 0,
  146. selectedList: [],
  147. isIceInfo: {},
  148. searchShow: true,
  149. }
  150. },
  151. onReachBottom() {
  152. if (!this.loadingMore) {
  153. this.getIceraftList()
  154. }
  155. },
  156. onLoad(option) {
  157. this.headline = option.name
  158. this.freezerId = option.freezerId
  159. },
  160. mounted() {
  161. var userInfo = this.$cache.getCache('userInfo')
  162. this.isIceInfo = userInfo.dept
  163. if (this.isIceInfo.isIceReleaseCold) {
  164. this.iceStateList = this.icelistil
  165. } else {
  166. this.iceStateList = this.icelist
  167. }
  168. this.getIceraftList()
  169. },
  170. methods: {
  171. // 搜索
  172. searchChange(value) {
  173. var that = this
  174. if (that.searchShow) {
  175. that.searchShow = false
  176. const timer = setTimeout(function() {
  177. clearTimeout(timer);
  178. that.PageIndex = 1
  179. that.list = []
  180. that.loadingMore = true
  181. that.getIceraftList()
  182. }, 300);
  183. }
  184. },
  185. // 获取冰排列表
  186. getIceraftList() {
  187. this.loadStatus = 'loading'
  188. this.loadingMore = true
  189. this.$api.get('/api/ice-locker/geticelocker', {
  190. page: this.PageIndex,
  191. pageSize: this.PageSize,
  192. code: this.keyword,
  193. status: this.iceState,
  194. LockerId: this.freezerId,
  195. }).then(res => {
  196. if (res.code == 200) {
  197. const data = res.data.list
  198. this.Total = res.data.count
  199. if (this.loadingMore == true && data) {
  200. this.list = this.list.concat(data);
  201. }
  202. this.getRecord()
  203. if (data.length < this.PageSize) {
  204. this.loadingMore = true
  205. this.loadStatus = 'nomore'
  206. } else {
  207. this.loadStatus = 'loading'
  208. this.loadingMore = false
  209. this.PageIndex++
  210. }
  211. }
  212. this.searchShow = true
  213. })
  214. },
  215. // 判断冰排是否选择
  216. getRecord() {
  217. this.list.forEach(item => {
  218. let index = this.selectedList.findIndex((event) => event === item.iceRaftRecord.id);
  219. if (index !== -1) {
  220. item.whetherFlag = true
  221. } else {
  222. item.whetherFlag = false
  223. }
  224. })
  225. this.$forceUpdate()
  226. },
  227. // 选择冰排
  228. choiceIce(event) {
  229. let index = this.selectedList.findIndex((item) => item === event.iceRaftRecord.id);
  230. // 如果有就替换,没有就添加
  231. if (index !== -1) {
  232. this.selectedList.splice(index, 1);
  233. } else {
  234. this.selectedList.push(event.iceRaftRecord.id);
  235. }
  236. if (this.isIceInfo.isIceReleaseCold) {
  237. this.getRecord()
  238. }
  239. },
  240. // 全选
  241. checkAll() {
  242. this.selectedList = []
  243. for (let i = 0; i < this.list.length; i++) {
  244. this.$set(this.list[i], 'whetherFlag', true)
  245. }
  246. this.list.forEach(item => {
  247. if (item.whetherFlag) {
  248. this.selectedList.push(item.iceRaftRecord.id)
  249. }
  250. })
  251. this.getRecord()
  252. },
  253. // 反选
  254. Inverse() {
  255. this.selectedList = []
  256. for (let i = 0; i < this.list.length; i++) {
  257. let flag = this.list[i].whetherFlag;
  258. this.$set(this.list[i], 'whetherFlag', !flag)
  259. }
  260. this.list.forEach(item => {
  261. if (item.whetherFlag) {
  262. this.selectedList.push(item.iceRaftRecord.id)
  263. }
  264. })
  265. this.getRecord()
  266. },
  267. // 出库释冷
  268. coolingRelease() {
  269. if (this.selectedList.length > 0) {
  270. uni.showLoading({
  271. mask: true
  272. });
  273. let arrID = this.selectedList.map(item => item.toString())
  274. this.$api.post('/api/ice-raft-record/start-for-cold', {
  275. id: arrID,
  276. }).then(res => {
  277. if (res.code == 200) {
  278. uni.$u.toast('操作成功')
  279. this.PageIndex = 1
  280. this.loadingMore = true
  281. this.list = []
  282. this.list.forEach(item => {
  283. item.whetherFlag = false
  284. })
  285. this.selectedList = []
  286. this.getIceraftList()
  287. } else {
  288. uni.$u.toast(res.msg)
  289. }
  290. uni.hideLoading();
  291. }).catch(() => {
  292. uni.hideLoading();
  293. })
  294. } else {
  295. uni.$u.toast('请先选择释冷冰排')
  296. }
  297. },
  298. matchingType(type) {
  299. let list = this.typeList
  300. let name = ''
  301. if (list) {
  302. list.forEach(item => {
  303. if (type === item.value) {
  304. name = item.label
  305. }
  306. })
  307. }
  308. return name
  309. },
  310. // tag颜色获取
  311. filterColor(type) {
  312. let list = this.typeList
  313. let color = ''
  314. if (list) {
  315. list.forEach(item => {
  316. if (type === item.value) {
  317. color = item.bgcolor
  318. }
  319. })
  320. }
  321. return color
  322. },
  323. // 总分钟格式化
  324. formatMinutes(totalMinutes) {
  325. const hours = Math.floor(totalMinutes / 60); // 计算小时
  326. const minutes = totalMinutes % 60; // 计算分钟(余数)
  327. return `${hours}h${minutes}m`;
  328. },
  329. // 扫一扫
  330. sweep() {
  331. // 允许从相机和相册扫码
  332. uni.scanCode({
  333. scanType: ['barCode'],
  334. // scanType: ['qrCode'],
  335. autoZoom: false,
  336. success: (res) => {
  337. // console.log(res);
  338. if (res.result) {
  339. let url = res.result;
  340. this.keyword = url
  341. } else {
  342. console.log('请重新扫描');
  343. return false;
  344. }
  345. },
  346. fail: (res) => {
  347. console.log('未识别到二维码');
  348. }
  349. })
  350. },
  351. // 冷冻要求
  352. getFreeze(event) {
  353. let title = event
  354. let arrList = []
  355. title.forEach(item => {
  356. let arr = '≥' + item + 'h'
  357. arrList.push(arr)
  358. })
  359. return arrList.toString()
  360. },
  361. sectionChange(event) {
  362. this.current = event.id
  363. if (event.id == 0) {
  364. this.iceState = null
  365. } else {
  366. this.iceState = String(event.id)
  367. }
  368. this.searchChange()
  369. },
  370. navbarHeight() {
  371. let systemInfo = uni.getSystemInfoSync();
  372. /* (750 / systemInfo.windowWidth) */
  373. /* 在uview navBar组件中有一个默认高度,当这个默认高度加上状态栏高度后就是吸顶的位置,由于这两者相加是px,所以最后还需要转为rpx */
  374. let topHeight = 0
  375. // #ifdef APP-PLUS
  376. topHeight = 44 + systemInfo.statusBarHeight;
  377. // #endif
  378. // #ifdef MP
  379. let height = systemInfo.platform == 'ios' ? 44 : 48;
  380. topHeight = height + systemInfo.statusBarHeight
  381. // #endif
  382. /* 最后一步将px转为rpx */
  383. return topHeight * (750 / systemInfo.windowWidth) / 2
  384. },
  385. }
  386. }
  387. </script>
  388. <style lang="scss">
  389. .search_card {
  390. display: flex;
  391. align-items: center;
  392. background-color: #fff;
  393. padding: 20rpx;
  394. }
  395. .card_tab_freezer {
  396. display: flex;
  397. align-items: center;
  398. justify-content: space-between;
  399. padding: 0rpx 20rpx 20rpx 20rpx;
  400. background-color: #fff;
  401. }
  402. .select_freezer {
  403. display: flex;
  404. align-items: flex-end;
  405. flex-direction: column;
  406. }
  407. .title_num {
  408. font-size: 26rpx;
  409. margin-left: 10rpx;
  410. }
  411. .select_title {
  412. font-size: 30rpx;
  413. margin-left: 15rpx;
  414. }
  415. .blue_color {
  416. color: #2979ff;
  417. }
  418. .green_color {
  419. color: #19be6b;
  420. }
  421. .orange_color {
  422. color: #ff9900;
  423. }
  424. .card_item_iceraft {
  425. position: relative;
  426. padding: 20rpx;
  427. margin: 20rpx;
  428. background-color: #fff;
  429. border-radius: 10rpx;
  430. overflow: hidden;
  431. }
  432. .position-triangle {
  433. position: absolute;
  434. bottom: 0;
  435. right: 0;
  436. overflow: hidden;
  437. height: 35px;
  438. width: 35px;
  439. }
  440. .position-triangle span {
  441. position: absolute;
  442. font-size: 20rpx;
  443. bottom: 8rpx;
  444. right: 3rpx;
  445. z-index: 1;
  446. color: #fff;
  447. transform: rotate(-45deg);
  448. }
  449. .position-triangle::after {
  450. content: "";
  451. font-size: 20rpx;
  452. position: absolute;
  453. width: 70px;
  454. height: 70px;
  455. background-color: #19be6b;
  456. transform: rotate(45deg);
  457. transform-origin: center;
  458. top: 50%;
  459. }
  460. .top_title {
  461. display: flex;
  462. }
  463. .title_Icecode {
  464. color: #000000;
  465. font-size: 32rpx;
  466. }
  467. .title_itemIce {
  468. color: #000000;
  469. font-size: 28rpx;
  470. margin-top: 10rpx;
  471. span {
  472. color: #19be6b;
  473. }
  474. }
  475. .card_input_fa {
  476. margin: 20rpx;
  477. padding: 12rpx 20rpx;
  478. line-height: 48rpx;
  479. border: 1rpx solid #e7e6e4;
  480. border-radius: 40rpx;
  481. background-color: #fff;
  482. }
  483. .card_btn_freezer {
  484. position: fixed;
  485. z-index: 2;
  486. bottom: 0;
  487. left: 0;
  488. right: 0;
  489. padding: 20rpx 30rpx 20rpx 30rpx;
  490. background-color: #fff;
  491. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  492. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  493. border-top: 1rpx solid #E4E7ED;
  494. }
  495. c .env_padding {
  496. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  497. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  498. }
  499. .card_subsection {
  500. display: flex;
  501. align-items: center;
  502. background-color: rgb(238, 238, 239);
  503. padding: 8rpx;
  504. border-radius: 6rpx;
  505. }
  506. .item_subsection {
  507. flex: 1;
  508. display: flex;
  509. justify-content: center;
  510. align-items: center;
  511. font-size: 24rpx;
  512. padding: 10rpx 0rpx;
  513. }
  514. .activate_subsection {
  515. flex: 1;
  516. display: flex;
  517. padding: 10rpx 0rpx;
  518. border-radius: 6rpx;
  519. justify-content: center;
  520. align-items: center;
  521. font-size: 24rpx;
  522. font-weight: bold;
  523. background-color: #fff;
  524. color: #2979ff;
  525. }
  526. </style>