IceManagement.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <view>
  3. <u-navbar title="冰排追溯管理" autoBack placeholder safeAreaInsetTop></u-navbar>
  4. <u-sticky :customNavHeight="navbarHeight()">
  5. <view class="search_card">
  6. <u-search :showAction="false" v-model="keyword" @change="searchChange"
  7. placeholder="请输入冰排编号查找"></u-search>
  8. <view style="margin-left: 10rpx;" @click="sweep">
  9. <u-icon name="scan" color="#606266" size="35"></u-icon>
  10. </view>
  11. </view>
  12. </u-sticky>
  13. <view style="display: flex;flex-direction: column;" v-if="list.length > 0">
  14. <view class="card_item_iceraft" v-for="(item,index) in list" :key="index">
  15. <view class="top_title space_between">
  16. <view class="title_Icecode">编号: <span>{{item.code}}</span></view>
  17. <view class="state_title_ice" :style="{color: filterColor(item.iceRaftRecord.status)}">
  18. {{matchingType(item.iceRaftRecord.status)}}
  19. </view>
  20. </view>
  21. <view class="title_itemIce">冰排备注:{{item.label}}</view>
  22. <view class="title_itemIce" v-if="item.iceRaftRecord.inStorageTime">入库时间:
  23. {{item.iceRaftRecord.inStorageTime}}
  24. </view>
  25. <view class="title_itemIce" v-if="item.iceRaftRecord.outStorageTime">出库时间:
  26. {{item.iceRaftRecord.outStorageTime}}
  27. </view>
  28. <view class="title_itemIce"
  29. v-if="item.iceRaftRecord.outStorageTime == '' && item.iceRaftRecord.iceLocker.name">所在位置:
  30. {{item.iceRaftRecord.iceLocker.name}}
  31. </view>
  32. <view class="title_itemIce"
  33. v-else-if="item.iceRaftRecord.outStorageTime != '' && item.iceRaftRecord.coolerBox.name">所在位置:
  34. {{item.iceRaftRecord.coolerBox.name}}
  35. </view>
  36. <view class="title_itemIce" v-if="item.iceRaftRecord.status != ''">冷冻要求:
  37. <span>{{getFreeze(item.iceRaftRecord.freezeClaim)}}</span>
  38. </view>
  39. <view class="title_itemIce" v-if="item.iceRaftRecord.status != ''">冷冻时间:
  40. <span>{{formatMinutes(item.iceRaftRecord.freezeDuration)}}</span>
  41. </view>
  42. </view>
  43. <view style="width: 100%;">
  44. <u-loadmore lineColor="#ffffff" :status="loadStatus" :key="Math.random()" />
  45. </view>
  46. </view>
  47. <view style="margin-top: 20%;" v-else>
  48. <u-empty mode="list" text="暂无冰排信息"></u-empty>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. list: [],
  57. typeList: [{
  58. bgcolor: '#606266',
  59. label: '未入库',
  60. value: '',
  61. }, {
  62. bgcolor: '#409EFF',
  63. label: '冷冻中',
  64. value: '1',
  65. }, {
  66. bgcolor: '#E6A23C',
  67. label: '待使用',
  68. value: '2',
  69. }, {
  70. bgcolor: '#67C23A',
  71. label: '使用中',
  72. value: '3',
  73. }, {
  74. bgcolor: '#909399',
  75. label: '已结束',
  76. value: '4',
  77. }, {
  78. bgcolor: '#ff9900',
  79. label: '释冷中',
  80. value: '4',
  81. }],
  82. PageIndex: 1,
  83. PageSize: 15,
  84. loadStatus: 'loadmore', //loading 、nomore
  85. loadingMore: true,
  86. keyword: '',
  87. }
  88. },
  89. onReachBottom() {
  90. if (!this.loadingMore) {
  91. this.getIceraftList()
  92. }
  93. },
  94. mounted() {
  95. this.getIceraftList()
  96. },
  97. methods: {
  98. // 搜索
  99. searchChange(value) {
  100. this.PageIndex = 1
  101. this.list = []
  102. this.loadingMore = true
  103. this.getIceraftList()
  104. },
  105. // 获取冰排列表
  106. getIceraftList() {
  107. this.loadStatus = 'loading'
  108. this.loadingMore = true
  109. this.$api.get('/api/ice-raft/newest-record', {
  110. page: this.PageIndex,
  111. pageSize: this.PageSize,
  112. code: this.keyword,
  113. }).then(res => {
  114. if (res.code == 200) {
  115. const data = res.data.list
  116. if (this.loadingMore == true && data) {
  117. this.list = this.list.concat(data);
  118. }
  119. if (data.length < this.PageSize) {
  120. this.loadingMore = true
  121. this.loadStatus = 'nomore'
  122. } else {
  123. this.loadStatus = 'loading'
  124. this.loadingMore = false
  125. this.PageIndex++
  126. }
  127. }
  128. })
  129. },
  130. // 冷冻要求
  131. getFreeze(event) {
  132. let title = event
  133. let arrList = []
  134. title.forEach(item => {
  135. let arr = '≥' + item + 'h'
  136. arrList.push(arr)
  137. })
  138. return arrList.toString()
  139. },
  140. matchingType(type) {
  141. let list = this.typeList
  142. let name = ''
  143. if (list) {
  144. list.forEach(item => {
  145. if (type === item.value) {
  146. name = item.label
  147. }
  148. })
  149. }
  150. return name
  151. },
  152. // tag颜色获取
  153. filterColor(type) {
  154. let list = this.typeList
  155. let color = ''
  156. if (list) {
  157. list.forEach(item => {
  158. if (type === item.value) {
  159. color = item.bgcolor
  160. }
  161. })
  162. }
  163. return color
  164. },
  165. // 总分钟格式化
  166. formatMinutes(totalMinutes) {
  167. const hours = Math.floor(totalMinutes / 60); // 计算小时
  168. const minutes = totalMinutes % 60; // 计算分钟(余数)
  169. return `${hours}h${minutes}m`;
  170. },
  171. // 扫一扫
  172. sweep() {
  173. // 允许从相机和相册扫码
  174. uni.scanCode({
  175. scanType: ['barCode'],
  176. // scanType: ['qrCode'],
  177. autoZoom: false,
  178. success: (res) => {
  179. // console.log(res);
  180. if (res.result) {
  181. let url = res.result;
  182. this.keyword = url
  183. } else {
  184. console.log('请重新扫描');
  185. return false;
  186. }
  187. },
  188. fail: (res) => {
  189. console.log('未识别到二维码');
  190. }
  191. })
  192. },
  193. navbarHeight() {
  194. let systemInfo = uni.getSystemInfoSync();
  195. /* (750 / systemInfo.windowWidth) */
  196. /* 在uview navBar组件中有一个默认高度,当这个默认高度加上状态栏高度后就是吸顶的位置,由于这两者相加是px,所以最后还需要转为rpx */
  197. let topHeight = 0
  198. // #ifdef APP-PLUS
  199. topHeight = 44 + systemInfo.statusBarHeight;
  200. // #endif
  201. // #ifdef MP
  202. let height = systemInfo.platform == 'ios' ? 44 : 48;
  203. topHeight = height + systemInfo.statusBarHeight
  204. // #endif
  205. /* 最后一步将px转为rpx */
  206. return topHeight * (750 / systemInfo.windowWidth) / 2
  207. },
  208. }
  209. }
  210. </script>
  211. <style lang="scss" scoped>
  212. .search_card {
  213. display: flex;
  214. align-items: center;
  215. background-color: #fff;
  216. padding: 20rpx;
  217. }
  218. .card_item_iceraft {
  219. padding: 20rpx;
  220. margin: 20rpx;
  221. background-color: #fff;
  222. border-radius: 10rpx;
  223. }
  224. .top_title {
  225. display: flex;
  226. }
  227. .title_Icecode {
  228. color: #000000;
  229. font-size: 30rpx;
  230. span {
  231. font-weight: bold;
  232. }
  233. }
  234. .state_title_ice {
  235. font-size: 30rpx;
  236. }
  237. .title_itemIce {
  238. color: #000000;
  239. font-size: 28rpx;
  240. margin-top: 10rpx;
  241. span {
  242. color: #19be6b;
  243. }
  244. }
  245. .card_input_fa {
  246. margin: 20rpx;
  247. padding: 12rpx 20rpx;
  248. line-height: 48rpx;
  249. border: 1rpx solid #e7e6e4;
  250. border-radius: 40rpx;
  251. background-color: #fff;
  252. }
  253. </style>