InService.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="in-service">
  3. <view class="card" v-for="(v , i) in data" :key="i">
  4. <uni-badge class="uni-badge-left-margin" :text="i+1" />
  5. <view class="text service">
  6. <text>产线名称</text>
  7. <text class="content">{{v.name}}</text>
  8. </view>
  9. <view class="text">
  10. <text>当前生产油品</text>
  11. <text class="content product">{{v.typeName}}</text>
  12. </view>
  13. <view class="text">
  14. <text>当前产线负责人</text>
  15. <text class="content">{{v.charger}}</text>
  16. </view>
  17. <view class="text">
  18. <text>当前作业工人</text>
  19. <text class="content">{{v.member}}</text>
  20. </view>
  21. <view class="text">
  22. <text>当前开始时间</text>
  23. <text class="content">{{getTime(v.startTime)}}</text>
  24. </view>
  25. <view class="text">
  26. <text>当前结束时间</text>
  27. <text class="content">{{v.endTime ? getTime(v.endTime) : '未结束'}}</text>
  28. </view>
  29. <view class="text">
  30. <text>当前作业时长</text>
  31. <text class="content">{{getJob(v.endTime,v.startTime)}}</text>
  32. </view>
  33. <view class="text">
  34. <text>当前产量</text>
  35. <view class="yield">
  36. <text class="content quantity">{{v.number}}箱</text>
  37. <button class="mini-btn" type="warn" size="mini" @click="goBack(v.name)">历史记录</button>
  38. </view>
  39. </view>
  40. <view class="text">
  41. <text>状态</text>
  42. <view class="state">
  43. <button class="mini-btn" size="mini">{{v.status == 0 ? '正在生产' : v.status == 1 ? '停止生产' : '暂停生产,整型'}}</button>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import { production } from '../../api/production.js'
  51. export default {
  52. data() {
  53. return {
  54. data: '',
  55. };
  56. },
  57. async created(){
  58. uni.showLoading({
  59. title: '加载中'
  60. });
  61. const res = await production({
  62. // name: '' // 不传参加载全部
  63. accessToken: uni.getStorageSync('tokenInfo'),
  64. account: uni.getStorageSync('account')
  65. })
  66. uni.hideLoading();
  67. this.data = res.data.list.filter(v => v.status == 0)
  68. },
  69. methods:{
  70. goBack(name){
  71. uni.navigateTo({
  72. url: '/pages/production/history?name='+ name
  73. });
  74. },
  75. // 获取时间
  76. getTime(time = new Date()) {
  77. let date = new Date(time);
  78. let year = date.getFullYear();
  79. let month = date.getMonth() + 1;
  80. let day = date.getDate();
  81. let hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours()
  82. let minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()
  83. month >= 1 && month <= 9 ? (month = "0" + month) : "";
  84. day >= 0 && day <= 9 ? (day = "0" + day) : "";
  85. let timer = year + '-' + month + '-' + day + ' ' + hour + ':'+ minute;
  86. return timer;
  87. },
  88. // 作业时间
  89. getJob(endTime,startTime){
  90. let EndTIME = endTime ? new Date(endTime).getTime() : new Date().getTime(); // 截止时间
  91. let NowTime = new Date(startTime).getTime(); // 开始时间
  92. let usedTime = EndTIME - NowTime; // 相差的毫秒数
  93. let days = Math.floor(usedTime / (24 * 3600 * 1000)); // 计算出天数
  94. let leavel = usedTime % (24 * 3600 * 1000); // 计算天数后剩余的时间
  95. let hours = Math.floor(leavel / (3600 * 1000)); // 计算剩余的小时数
  96. let leavel2 = leavel % (3600 * 1000); // 计算剩余小时后剩余的毫秒数
  97. let minutes = Math.floor(leavel2 / (60 * 1000)); // 计算剩余的分钟数
  98. return days + '天' + hours + '小时' + minutes + '分钟';
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss">
  104. .in-service{
  105. padding: 0 20rpx;
  106. .card{
  107. padding-top: 10rpx;
  108. border-bottom: 15rpx solid #ebebeb;
  109. .text{
  110. padding: 25rpx 0;
  111. display: flex;
  112. justify-content: space-between;
  113. border-bottom: 1px solid #d9d9d9;
  114. &.service{
  115. padding-top: 0;
  116. }
  117. &:last-child{
  118. border-bottom: 0;
  119. }
  120. .content{
  121. color: #737373;
  122. }
  123. .product{
  124. color: #2d76c9;
  125. width: 50%;
  126. text-align: right;
  127. }
  128. .quantity{
  129. color: #e40315;
  130. }
  131. .yield{
  132. display: flex;
  133. align-items: center;
  134. .mini-btn{
  135. margin-left: 20rpx;
  136. }
  137. }
  138. .state{
  139. .mini-btn{
  140. background-color: #85d691;
  141. color: #fff;
  142. }
  143. }
  144. }
  145. }
  146. }
  147. </style>