IceManagement.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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: '5',
  81. }, {
  82. bgcolor: '#67C23A',
  83. label: '释冷完成',
  84. value: '6',
  85. }],
  86. PageIndex: 1,
  87. PageSize: 15,
  88. loadStatus: 'loadmore', //loading 、nomore
  89. loadingMore: true,
  90. keyword: '',
  91. }
  92. },
  93. onReachBottom() {
  94. if (!this.loadingMore) {
  95. this.getIceraftList()
  96. }
  97. },
  98. mounted() {
  99. this.getIceraftList()
  100. },
  101. methods: {
  102. // 搜索
  103. searchChange(value) {
  104. this.PageIndex = 1
  105. this.list = []
  106. this.loadingMore = true
  107. this.getIceraftList()
  108. },
  109. // 获取冰排列表
  110. getIceraftList() {
  111. this.loadStatus = 'loading'
  112. this.loadingMore = true
  113. this.$api.get('/api/ice-raft/newest-record', {
  114. page: this.PageIndex,
  115. pageSize: this.PageSize,
  116. code: this.keyword,
  117. }).then(res => {
  118. if (res.code == 200) {
  119. const data = res.data.list
  120. if (this.loadingMore == true && data) {
  121. this.list = this.list.concat(data);
  122. }
  123. if (data.length < this.PageSize) {
  124. this.loadingMore = true
  125. this.loadStatus = 'nomore'
  126. } else {
  127. this.loadStatus = 'loading'
  128. this.loadingMore = false
  129. this.PageIndex++
  130. }
  131. }
  132. })
  133. },
  134. // 冷冻要求
  135. getFreeze(event) {
  136. let title = event
  137. let arrList = []
  138. title.forEach(item => {
  139. let arr = '≥' + item + 'h'
  140. arrList.push(arr)
  141. })
  142. return arrList.toString()
  143. },
  144. matchingType(type) {
  145. let list = this.typeList
  146. let name = ''
  147. if (list) {
  148. list.forEach(item => {
  149. if (type === item.value) {
  150. name = item.label
  151. }
  152. })
  153. }
  154. return name
  155. },
  156. // tag颜色获取
  157. filterColor(type) {
  158. let list = this.typeList
  159. let color = ''
  160. if (list) {
  161. list.forEach(item => {
  162. if (type === item.value) {
  163. color = item.bgcolor
  164. }
  165. })
  166. }
  167. return color
  168. },
  169. // 总分钟格式化
  170. formatMinutes(totalMinutes) {
  171. const hours = Math.floor(totalMinutes / 60); // 计算小时
  172. const minutes = totalMinutes % 60; // 计算分钟(余数)
  173. return `${hours}h${minutes}m`;
  174. },
  175. // 扫一扫
  176. sweep() {
  177. // 允许从相机和相册扫码
  178. uni.scanCode({
  179. scanType: ['barCode'],
  180. // scanType: ['qrCode'],
  181. autoZoom: false,
  182. success: (res) => {
  183. // console.log(res);
  184. if (res.result) {
  185. let url = res.result;
  186. this.keyword = url
  187. } else {
  188. console.log('请重新扫描');
  189. return false;
  190. }
  191. },
  192. fail: (res) => {
  193. console.log('未识别到二维码');
  194. }
  195. })
  196. },
  197. navbarHeight() {
  198. let systemInfo = uni.getSystemInfoSync();
  199. /* (750 / systemInfo.windowWidth) */
  200. /* 在uview navBar组件中有一个默认高度,当这个默认高度加上状态栏高度后就是吸顶的位置,由于这两者相加是px,所以最后还需要转为rpx */
  201. let topHeight = 0
  202. // #ifdef APP-PLUS
  203. topHeight = 44 + systemInfo.statusBarHeight;
  204. // #endif
  205. // #ifdef MP
  206. let height = systemInfo.platform == 'ios' ? 44 : 48;
  207. topHeight = height + systemInfo.statusBarHeight
  208. // #endif
  209. /* 最后一步将px转为rpx */
  210. return topHeight * (750 / systemInfo.windowWidth) / 2
  211. },
  212. }
  213. }
  214. </script>
  215. <style lang="scss" scoped>
  216. .search_card {
  217. display: flex;
  218. align-items: center;
  219. background-color: #fff;
  220. padding: 20rpx;
  221. }
  222. .card_item_iceraft {
  223. padding: 20rpx;
  224. margin: 20rpx;
  225. background-color: #fff;
  226. border-radius: 10rpx;
  227. }
  228. .top_title {
  229. display: flex;
  230. }
  231. .title_Icecode {
  232. color: #000000;
  233. font-size: 30rpx;
  234. span {
  235. font-weight: bold;
  236. }
  237. }
  238. .state_title_ice {
  239. font-size: 30rpx;
  240. }
  241. .title_itemIce {
  242. color: #000000;
  243. font-size: 28rpx;
  244. margin-top: 10rpx;
  245. span {
  246. color: #19be6b;
  247. }
  248. }
  249. .card_input_fa {
  250. margin: 20rpx;
  251. padding: 12rpx 20rpx;
  252. line-height: 48rpx;
  253. border: 1rpx solid #e7e6e4;
  254. border-radius: 40rpx;
  255. background-color: #fff;
  256. }
  257. </style>