index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <view class="uni-column container">
  3. <view class="uni-row" style="position: fixed;
  4. top: 0;width: 100%;
  5. height: 120rpx;
  6. z-index: 2;
  7. margin:0 auto;
  8. background-color: white;
  9. justify-content: space-around;
  10. align-items: center;
  11. border-top: 1rpx solid lightgray;
  12. border-bottom: 1rpx solid lightgray;">
  13. <uni-section title="选择日期:" type="square" class="uni-row">
  14. <uni-data-select v-model="selectDate" :localdata="dateList" @change="change"
  15. :clear="false" style="width: 280rpx;"></uni-data-select>
  16. </uni-section>
  17. <uni-section title="条数:" type="square" class="uni-row" style="justify-content: center;align-items: center;">
  18. {{ listDataItem.length }}
  19. </uni-section>
  20. </view>
  21. <view class="scroll-container">
  22. <view v-for="(item, index) in listDataItem" :key="index" class="list-item">
  23. <view class="title-container">
  24. <view class="title uni-row">
  25. <view class="uni-row">
  26. <text class="label">批次号:</text>
  27. <text class="label code"> {{ item['lotCode'] }}</text>
  28. </view>
  29. <!-- <view style="color: #1684fc; margin-right: 0;" @click="handleOpenLonInfo">
  30. <text>批次详情</text>
  31. </view> -->
  32. </view>
  33. <view class="uni-row" style="margin: 10rpx 0 0;">
  34. <view class="right-info uni-row"> <text class="label">工时</text>
  35. <text class="label time">{{ item['taskTime'] }}</text>
  36. </view>
  37. <view class="right-info uni-row" style="margin-left: 50rpx;"> <text class="label">合格数</text>
  38. <text class="label number ">{{ item['qualifiedNum'] }}</text>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="item-info uni-row">
  43. <text class="label">产品描述</text>
  44. <text class="label right">{{ item['productDescription'] }}</text>
  45. </view>
  46. <!-- <view class="item-info uni-row">
  47. <text class="label">操作者</text>
  48. <text class="label right">{{ item['nickName'] }}</text>
  49. </view> -->
  50. <view class="item-info uni-row">
  51. <text class="label">开始时间</text>
  52. <text class="label right">{{ item['startTime'] ? item['startTime'] : '-' }}</text>
  53. </view>
  54. <view class="item-info uni-row">
  55. <text class="label">结束时间</text>
  56. <text class="label right">{{ item['endTime'] ? item['endTime'] : '-'}}</text>
  57. </view>
  58. <view class="item-info uni-row">
  59. <text class="label">废品数</text>
  60. <text class="label right">{{ item['rejectSum'] ? item['rejectSum'] : 0 }}</text>
  61. </view>
  62. <!-- <view class="item-info uni-row">
  63. <text class="label">投入数</text>
  64. <text
  65. class="label right">{{}}</text>
  66. </view> -->
  67. <view class="item-info uni-row">
  68. <text class="label">设备</text>
  69. <text class="label right">{{ item['equipmentDetailCode'] }}</text>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- <dialog-lotInfo ref="lotInfo"></dialog-lotInfo> -->
  75. </template>
  76. <script setup>
  77. import {
  78. ref
  79. } from 'vue'
  80. import {
  81. onLoad,
  82. onShow
  83. } from '@dcloudio/uni-app'
  84. import {
  85. getDayWorkItemHistory
  86. } from "@/api/business/dayWorkItem.js"
  87. import {
  88. store
  89. } from '@/store/index.js'
  90. import {
  91. toHHmmss
  92. } from '@/utils/common.js'
  93. const listData = ref([]) // 回显
  94. const listDataItem = ref([])
  95. const lotInfo = ref(null) // 详情弹窗
  96. const selectDate = ref('')
  97. const dateList = ref([])
  98. onLoad(() => {
  99. })
  100. onShow(() => {
  101. init();
  102. })
  103. function init() {
  104. uni.showLoading({
  105. title: '加载中'
  106. });
  107. getDayWorkItemHistory().then(res => {
  108. if (res.code == 200) {
  109. listData.value = res.rows || [];
  110. // 时间戳转工时
  111. for (var i = 0; i < listData.value.length; i++) {
  112. let timeStamp = listData.value[i].workingHours;
  113. listData.value[i].taskTime = toHHmmss(timeStamp);
  114. }
  115. // 转为二维数组
  116. console.log(listData.value)
  117. const groupedData = listData.value.reduce((accumulator, currentItem) => {
  118. // 获取当前对象的日期字符串
  119. const dateString = currentItem.startTime.split(' ')[0];
  120. // 如果有这个日期,则 push 到对应的数组中,否则创建一个新的数组
  121. if (accumulator[dateString]) {
  122. accumulator[dateString].push(currentItem);
  123. } else {
  124. accumulator[dateString] = [currentItem];
  125. }
  126. return accumulator;
  127. }, {});
  128. // 时间下拉
  129. for (let i = 0; i < Object.keys(groupedData).length; i++) {
  130. dateList.value[i] = {
  131. text: Object.keys(groupedData)[i],
  132. value: Object.keys(groupedData)[i]
  133. }
  134. }
  135. listData.value = groupedData;
  136. listDataItem.value = listData.value[dateList.value[0].value]
  137. selectDate.value = dateList.value[0].value;
  138. console.log(groupedData)
  139. uni.hideLoading();
  140. } else {
  141. uni.showToast({
  142. icon: "none",
  143. title: res.message,
  144. duration: 2000
  145. })
  146. uni.hideLoading();
  147. }
  148. })
  149. }
  150. function change() {
  151. listDataItem.value = listData.value[selectDate.value]
  152. }
  153. // function handleOpenLonInfo() {
  154. // lotInfo.value.open();
  155. // }
  156. </script>
  157. <style lang="scss">
  158. .container {
  159. background-color: #f5f5f5;
  160. overflow: auto;
  161. }
  162. .scroll-container {
  163. position: relative;
  164. top: 140rpx;
  165. }
  166. .selected {
  167. border: 1px solid #1684fc;
  168. }
  169. .list-item {
  170. background-color: #fff;
  171. position: relative;
  172. padding: 16rpx;
  173. padding-bottom: 24rpx;
  174. margin: 0 24rpx;
  175. margin-bottom: 24rpx;
  176. border-radius: 8rpx;
  177. .title-container {
  178. margin: 8rpx 0;
  179. width: 100%;
  180. .title {
  181. height: 48rpx;
  182. justify-content: space-between;
  183. align-items: center;
  184. flex: 7;
  185. .label {
  186. font-weight: bold;
  187. }
  188. .code {
  189. margin-left: 8rpx;
  190. }
  191. }
  192. }
  193. .item-info {
  194. margin-bottom: 8rpx;
  195. .label {
  196. font-size: 28rpx;
  197. width: 152rpx;
  198. color: #808080;
  199. &.right {
  200. flex: 1;
  201. color: #000000;
  202. }
  203. }
  204. }
  205. .right-info {
  206. .label {
  207. font-size: 28rpx;
  208. }
  209. .time {
  210. margin-left: 8rpx;
  211. color: #1684fc;
  212. }
  213. .number {
  214. margin-left: 8rpx;
  215. color: #1684fc;
  216. }
  217. }
  218. }
  219. </style>