IceManagement.vue 6.1 KB

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