index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <view class="uni-column container" >
  3. <scroll-view class="scroll-container" scroll-y>
  4. <view v-for="(item, index) in listData" :key="index"
  5. :class="{'list-item':true,'selected':selectedItem === item}" @click="handleSelection(item)">
  6. <view class="title-container uni-row">
  7. <view class="title uni-row">
  8. <text class="label">批次号:</text>
  9. <text class="label code">{{ item['lotCode'] }}</text>
  10. </view>
  11. <view class="right-info uni-row">
  12. <view class="right-info uni-row"> <text class="label ">工时</text>
  13. <text class="label time">{{ item['taskTime'] }}h</text>
  14. </view>
  15. <view class="right-info uni-row" style="margin-left:32px;"> <text class="label">合格数</text>
  16. <text class="label number ">{{ item['qualifiedQuantity'] }}</text>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="item-info uni-row">
  21. <text class="label">操作者</text>
  22. <text class="label right">{{ item['nickName'] }}</text>
  23. </view>
  24. <view class="item-info uni-row">
  25. <text class="label">开始时间</text>
  26. <text class="label right">{{ item['startTime']}}</text>
  27. </view>
  28. <view class="item-info uni-row">
  29. <text class="label">结束时间</text>
  30. <text class="label right">{{ (item['endTime'] !="")?item['endTime']:'-'}}</text>
  31. </view>
  32. <view class="item-info uni-row">
  33. <text class="label">废品数</text>
  34. <text class="label right">{{ item['rejectNum']}}</text>
  35. </view>
  36. <view class="item-info uni-row">
  37. <text class="label">废品原因</text>
  38. <text class="label right">{{ (item['remark'] != "")?item['remark']:'-'}}</text>
  39. </view>
  40. <view v-if="item['status'] == 0" class="status-btn uni-row ">
  41. <button class="finished-turnover-tag" size="mini"
  42. @click.stop="handleShowEndWorkDialog(item)">结束报工</button>
  43. </view>
  44. </view>
  45. </scroll-view>
  46. <view class="bottom uni-row">
  47. <button class="bottom-btn left-btn" @click="HandleChangevehicle"><text class="label">更换载具</text></button>
  48. <button class="bottom-btn right-btn" @click="handleStartProcessing"><text class="label">开始加工</text></button>
  49. </view>
  50. <dialog-end-work ref="endWorkDialog" @sendEquipment='getEquipment' @reset="reset"/>
  51. <dialog-selectEquipment ref='selectEquipment'></dialog-selectEquipment>
  52. </view>
  53. </template>
  54. <script setup>
  55. import {
  56. ref
  57. } from 'vue'
  58. import {
  59. onLoad,
  60. onReady
  61. } from '@dcloudio/uni-app'
  62. import { getDayWorkItemList,saveDayWorkItem } from "@/api/business/dayWorkItem.js"
  63. const listData = ref([])
  64. const curSubDetails = ref({})
  65. const selectedItem = ref({})
  66. const endWorkDialog = ref(null)
  67. const selectEquipment = ref(null)
  68. const equipmentList = ref([])
  69. onLoad((options) => {
  70. curSubDetails.value = options.currentSubPlan;
  71. console.log(JSON.parse(curSubDetails.value))
  72. init();
  73. })
  74. function init(){
  75. getDayWorkItemList().then(res => {
  76. listData.value = res.rows;
  77. console.log(listData)
  78. })
  79. }
  80. function reset(){
  81. init();
  82. }
  83. function handleSelection(item){
  84. if (selectedItem.value === item) {
  85. selectedItem.value = null;
  86. } else {
  87. selectedItem.value = item;
  88. }
  89. }
  90. function handleShowEndWorkDialog(data){
  91. // 调用子组件中的方法
  92. endWorkDialog.value.open(data)
  93. }
  94. function HandleChangevehicle(){
  95. uni.navigateTo({
  96. url:"/pages/changeBox/index"
  97. })
  98. }
  99. function getEquipment(data){
  100. console.log(data);
  101. equipmentList.value = data;
  102. }
  103. function handleStartProcessing(){
  104. selectEquipment.value.open();
  105. let date = new Date()
  106. saveDayWorkItem({
  107. dayworkId: '1',
  108. startTime: date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate()
  109. }).then(res => {
  110. if(res.code === 200){
  111. uni.showToast({
  112. icon: 'success',
  113. title: '操作成功',
  114. duration: 2000
  115. });
  116. init();
  117. }else{
  118. uni.showToast({
  119. icon: 'error',
  120. title: '操作失败',
  121. duration: 2000
  122. });
  123. }
  124. })
  125. }
  126. </script>
  127. <style lang="scss">
  128. .container {
  129. height: 2000rpx;
  130. background-color: #f5f5f5;
  131. overflow: auto;
  132. }
  133. .scroll-container {
  134. position: absolute;
  135. top: 24rpx;
  136. right: 0;
  137. bottom: 144rpx;
  138. left: 0;
  139. }
  140. .selected {
  141. border: 1px solid #1684fc;
  142. }
  143. .list-item {
  144. background-color: #fff;
  145. position: relative;
  146. padding: 16rpx;
  147. padding-bottom: 24rpx;
  148. margin: 0 24rpx;
  149. margin-bottom: 24rpx;
  150. border-radius: 8rpx;
  151. .title-container {
  152. justify-content: space-between;
  153. margin-top: 8rpx;
  154. margin-bottom: 16rpx;
  155. .title {
  156. height: 48rpx;
  157. align-items: center;
  158. .label {
  159. font-size: 32rpx;
  160. font-weight: bold;
  161. &.code {
  162. margin-left: 8rpx;
  163. }
  164. }
  165. }
  166. }
  167. .item-info {
  168. margin-bottom: 8rpx;
  169. .label {
  170. font-size: 28rpx;
  171. width: 152rpx;
  172. color: #808080;
  173. &.right {
  174. flex: 1;
  175. color: #000000;
  176. }
  177. }
  178. }
  179. .right-info {
  180. justify-content: flex-end;
  181. margin-top: 5rpx;
  182. .label {
  183. font-size: 28rpx;
  184. color: #000000;
  185. &.time {
  186. margin-left: 8rpx;
  187. color: #1684fc;
  188. }
  189. &.number {
  190. margin-left: 8rpx;
  191. color: rgba(0, 226, 166, 1);
  192. }
  193. }
  194. }
  195. }
  196. .bottom {
  197. position: fixed;
  198. right: 0;
  199. bottom: 0;
  200. left: 0;
  201. height: 100rpx;
  202. padding: 16rpx 24rpx;
  203. align-items: center;
  204. background-color: #FFFFFF;
  205. justify-content: space-between;
  206. .bottom-btn {
  207. flex: 1;
  208. font-size: 28rpx;
  209. color: #FFFFFF;
  210. &.left-btn {
  211. background-color: #1684fc;
  212. }
  213. &.right-btn {
  214. background-color: rgb(255, 121, 1);
  215. margin-left: 24rpx;
  216. }
  217. }
  218. }
  219. .status-btn {
  220. width: 100%;
  221. justify-content: flex-end;
  222. .finished-turnover-tag {
  223. margin: unset;
  224. border-radius: 8rpx;
  225. background-color: rgb(255, 85, 85);
  226. font-size: 28rpx;
  227. color: #FFFFFF;
  228. }
  229. }
  230. </style>