NotRun.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view class="not-run">
  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. onLoad() {
  58. },
  59. async created() {
  60. uni.showLoading({
  61. title: '加载中'
  62. });
  63. const res = await production({
  64. // name: '' // 不传参加载全部
  65. accessToken: uni.getStorageSync('tokenInfo'),
  66. account: uni.getStorageSync('account')
  67. })
  68. uni.hideLoading();
  69. this.data = res.data.list.filter(v => v.status !== 0)
  70. },
  71. methods:{
  72. goBack(name){
  73. uni.navigateTo({
  74. url: '/pages/production/history?name='+ name
  75. });
  76. },
  77. // 获取时间
  78. getTime(time = new Date()) {
  79. let date = new Date(time);
  80. let year = date.getFullYear();
  81. let month = date.getMonth() + 1;
  82. let day = date.getDate();
  83. let hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours()
  84. let minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()
  85. month >= 1 && month <= 9 ? (month = "0" + month) : "";
  86. day >= 0 && day <= 9 ? (day = "0" + day) : "";
  87. let timer = year + '-' + month + '-' + day + ' ' + hour + ':'+ minute;
  88. return timer;
  89. },
  90. // 作业时间
  91. getJob(endTime,startTime){
  92. let EndTIME = endTime ? new Date(endTime).getTime() : new Date().getTime(); // 截止时间
  93. let NowTime = new Date(startTime).getTime(); // 开始时间
  94. let usedTime = EndTIME - NowTime; // 相差的毫秒数
  95. let days = Math.floor(usedTime / (24 * 3600 * 1000)); // 计算出天数
  96. let leavel = usedTime % (24 * 3600 * 1000); // 计算天数后剩余的时间
  97. let hours = Math.floor(leavel / (3600 * 1000)); // 计算剩余的小时数
  98. let leavel2 = leavel % (3600 * 1000); // 计算剩余小时后剩余的毫秒数
  99. let minutes = Math.floor(leavel2 / (60 * 1000)); // 计算剩余的分钟数
  100. return days + '天' + hours + '小时' + minutes + '分钟';
  101. }
  102. }
  103. }
  104. </script>
  105. <style lang="scss">
  106. .not-run{
  107. padding: 0 20rpx;
  108. .card{
  109. padding-top: 10rpx;
  110. border-bottom: 15rpx solid #ebebeb;
  111. .text{
  112. padding: 25rpx 0;
  113. display: flex;
  114. justify-content: space-between;
  115. border-bottom: 1px solid #d9d9d9;
  116. &.service{
  117. padding-top: 0;
  118. }
  119. &:last-child{
  120. border-bottom: 0;
  121. }
  122. .content{
  123. color: #737373;
  124. }
  125. .product{
  126. color: #2d76c9;
  127. width: 50%;
  128. text-align: right;
  129. }
  130. .quantity{
  131. color: #e40315;
  132. }
  133. .yield{
  134. display: flex;
  135. align-items: center;
  136. .mini-btn{
  137. margin-left: 20rpx;
  138. }
  139. }
  140. .state{
  141. .mini-btn{
  142. background-color: #e56482;
  143. color: #fff;
  144. }
  145. }
  146. }
  147. }
  148. }
  149. </style>