freezer.vue 11 KB

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