freezer.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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>≥{{item.iceRaftRecord.freezeClaim}}h</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. }
  227. })
  228. } else {
  229. uni.$u.toast('请先选择释冷冰排')
  230. }
  231. },
  232. matchingType(type) {
  233. let list = this.typeList
  234. let name = ''
  235. if (list) {
  236. list.forEach(item => {
  237. if (type === item.value) {
  238. name = item.label
  239. }
  240. })
  241. }
  242. return name
  243. },
  244. // tag颜色获取
  245. filterColor(type) {
  246. let list = this.typeList
  247. let color = ''
  248. if (list) {
  249. list.forEach(item => {
  250. if (type === item.value) {
  251. color = item.bgcolor
  252. }
  253. })
  254. }
  255. return color
  256. },
  257. // 总分钟格式化
  258. formatMinutes(totalMinutes) {
  259. const hours = Math.floor(totalMinutes / 60); // 计算小时
  260. const minutes = totalMinutes % 60; // 计算分钟(余数)
  261. return `${hours}h${minutes}m`;
  262. },
  263. // 扫一扫
  264. sweep() {
  265. // 允许从相机和相册扫码
  266. uni.scanCode({
  267. scanType: ['barCode'],
  268. // scanType: ['qrCode'],
  269. autoZoom: false,
  270. success: (res) => {
  271. // console.log(res);
  272. if (res.result) {
  273. let url = res.result;
  274. this.keyword = url
  275. } else {
  276. console.log('请重新扫描');
  277. return false;
  278. }
  279. },
  280. fail: (res) => {
  281. console.log('未识别到二维码');
  282. }
  283. })
  284. },
  285. sectionChange(index) {
  286. this.current = index
  287. if (index == 0) {
  288. this.iceState = null
  289. } else {
  290. this.iceState = String(index)
  291. }
  292. this.searchChange()
  293. },
  294. navbarHeight() {
  295. let systemInfo = uni.getSystemInfoSync();
  296. /* (750 / systemInfo.windowWidth) */
  297. /* 在uview navBar组件中有一个默认高度,当这个默认高度加上状态栏高度后就是吸顶的位置,由于这两者相加是px,所以最后还需要转为rpx */
  298. let topHeight = 0
  299. // #ifdef APP-PLUS
  300. topHeight = 44 + systemInfo.statusBarHeight;
  301. // #endif
  302. // #ifdef MP
  303. let height = systemInfo.platform == 'ios' ? 44 : 48;
  304. topHeight = height + systemInfo.statusBarHeight
  305. // #endif
  306. /* 最后一步将px转为rpx */
  307. return topHeight * (750 / systemInfo.windowWidth) / 2
  308. },
  309. }
  310. }
  311. </script>
  312. <style lang="scss">
  313. .search_card {
  314. display: flex;
  315. align-items: center;
  316. background-color: #fff;
  317. padding: 20rpx;
  318. }
  319. .card_tab_freezer {
  320. display: flex;
  321. align-items: center;
  322. justify-content: space-between;
  323. padding: 0rpx 20rpx 20rpx 20rpx;
  324. background-color: #fff;
  325. }
  326. .select_freezer {
  327. display: flex;
  328. align-items: flex-end;
  329. // flex-direction: column;
  330. }
  331. .title_num {
  332. font-size: 26rpx;
  333. margin-left: 10rpx;
  334. }
  335. .select_title {
  336. font-size: 30rpx;
  337. margin-left: 15rpx;
  338. }
  339. .blue_color {
  340. color: #2979ff;
  341. }
  342. .green_color {
  343. color: #19be6b;
  344. }
  345. .orange_color {
  346. color: #ff9900;
  347. }
  348. .card_item_iceraft {
  349. position: relative;
  350. padding: 20rpx;
  351. margin: 20rpx;
  352. background-color: #fff;
  353. border-radius: 10rpx;
  354. overflow: hidden;
  355. }
  356. .position-triangle {
  357. position: absolute;
  358. bottom: 0;
  359. right: 0;
  360. overflow: hidden;
  361. height: 35px;
  362. width: 35px;
  363. }
  364. .position-triangle span {
  365. position: absolute;
  366. font-size: 20rpx;
  367. bottom: 8rpx;
  368. right: 3rpx;
  369. z-index: 1;
  370. color: #fff;
  371. transform: rotate(-45deg);
  372. }
  373. .position-triangle::after {
  374. content: "";
  375. font-size: 20rpx;
  376. position: absolute;
  377. width: 70px;
  378. height: 70px;
  379. background-color: #19be6b;
  380. transform: rotate(45deg);
  381. transform-origin: center;
  382. top: 50%;
  383. }
  384. .top_title {
  385. display: flex;
  386. }
  387. .title_Icecode {
  388. color: #000000;
  389. font-size: 32rpx;
  390. }
  391. .title_itemIce {
  392. color: #000000;
  393. font-size: 30rpx;
  394. margin-top: 10rpx;
  395. span {
  396. color: #19be6b;
  397. }
  398. }
  399. .card_input_fa {
  400. margin: 20rpx;
  401. padding: 12rpx 20rpx;
  402. line-height: 48rpx;
  403. border: 1rpx solid #e7e6e4;
  404. border-radius: 40rpx;
  405. background-color: #fff;
  406. }
  407. .card_btn_freezer {
  408. position: fixed;
  409. z-index: 2;
  410. bottom: 0;
  411. left: 0;
  412. right: 0;
  413. padding: 20rpx 30rpx 20rpx 30rpx;
  414. background-color: #fff;
  415. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  416. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  417. border-top: 1rpx solid #E4E7ED;
  418. }
  419. .env_padding {
  420. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  421. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  422. }
  423. </style>