index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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':isSelected(index)}" @click="handleSelection(item,index)">
  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="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="handleAddItem"><text class="label">开始加工</text></button>
  49. </view>
  50. <dialog-end-work ref="endWorkDialog" />
  51. </view>
  52. </template>
  53. <script setup>
  54. import {
  55. ref
  56. } from 'vue'
  57. import {
  58. onLoad,
  59. onReady
  60. } from '@dcloudio/uni-app'
  61. import { getDayWorkItemList,saveDayWorkItem } from "@/api/business/dayWorkItem.js"
  62. const listData = ref([{
  63. equipment: "051-7",
  64. taskTime: 2.8,
  65. qualifiedQuantity: 0,
  66. operator: "张三",
  67. jobNumber: 15223,
  68. startTime: "2023.05.06 14:23",
  69. endTime: "",
  70. rejectNumber: 0,
  71. refectReason: "*******",
  72. status: 0
  73. },
  74. {
  75. equipment: "051-7",
  76. taskTime: 3.6,
  77. qualifiedQuantity: 300,
  78. operator: "张三",
  79. jobNumber: 15223,
  80. startTime: "2023.05.06 14:23",
  81. endTime: "2023.05.06 18:23",
  82. rejectNumber: 0,
  83. refectReason: "",
  84. status: 1
  85. },
  86. {
  87. equipment: "051-7",
  88. taskTime: 3.6,
  89. qualifiedQuantity: 300,
  90. operator: "张三",
  91. jobNumber: 15223,
  92. startTime: "2023.05.06 14:23",
  93. endTime: "2023.05.06 18:23",
  94. rejectNumber: 0,
  95. refectReason: "",
  96. status: 1
  97. },
  98. {
  99. equipment: "051-7",
  100. taskTime: 3.6,
  101. qualifiedQuantity: 300,
  102. operator: "张三",
  103. jobNumber: 15223,
  104. startTime: "2023.05.06 14:23",
  105. endTime: "2023.05.06 18:23",
  106. rejectNumber: 0,
  107. refectReason: "",
  108. status: 0
  109. },
  110. {
  111. equipment: "051-7",
  112. taskTime: 3.6,
  113. qualifiedQuantity: 300,
  114. operator: "张三",
  115. jobNumber: 15223,
  116. startTime: "2023.05.06 14:23",
  117. endTime: "2023.05.06 18:23",
  118. rejectNumber: 0,
  119. refectReason: "",
  120. status: 1
  121. }
  122. ])
  123. const selection = ref([])
  124. const endWorkDialog = ref(null)
  125. onReady(() => {
  126. init();
  127. })
  128. function init(){
  129. getDayWorkItemList().then(res => {
  130. listData.value = res.rows;
  131. console.log(listData)
  132. })
  133. }
  134. const isSelected = (index) => {
  135. return selection.value.includes(index)
  136. }
  137. const handleSelection = (item,index) => {
  138. const buttonIndex = selection.value.indexOf(index);
  139. if (buttonIndex > -1) {
  140. selection.value.splice(buttonIndex, 1); // 取消选中
  141. } else {
  142. selection.value.push(index); // 选中
  143. }
  144. }
  145. const handleShowEndWorkDialog = (data) => {
  146. let _data = data ?? {}
  147. // 调用子组件中的方法
  148. endWorkDialog.value.open(_data)
  149. }
  150. function HandleChangevehicle(){
  151. uni.navigateTo({
  152. url:"/pages/changeBox/index"
  153. })
  154. }
  155. function handleAddItem(){
  156. console.log("111111111111111111111111")
  157. let date = new Date()
  158. saveDayWorkItem({
  159. dayworkId: '1',
  160. startTime: date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate()
  161. }).then(res => {
  162. if(res.code === 200){
  163. uni.showToast({
  164. icon: 'success',
  165. title: '操作成功',
  166. duration: 2000
  167. });
  168. }else{
  169. uni.showToast({
  170. icon: 'error',
  171. title: '操作失败',
  172. duration: 2000
  173. });
  174. }
  175. })
  176. }
  177. </script>
  178. <style lang="scss">
  179. .container {
  180. height: 2000rpx;
  181. background-color: #f5f5f5;
  182. overflow: auto;
  183. }
  184. .scroll-container {
  185. position: absolute;
  186. top: 24rpx;
  187. right: 0;
  188. bottom: 144rpx;
  189. left: 0;
  190. }
  191. .selected {
  192. border: 1px solid #1684fc;
  193. }
  194. .list-item {
  195. background-color: #fff;
  196. position: relative;
  197. padding: 16rpx;
  198. padding-bottom: 24rpx;
  199. margin: 0 24rpx;
  200. margin-bottom: 24rpx;
  201. border-radius: 8rpx;
  202. .title-container {
  203. justify-content: space-between;
  204. margin-top: 8rpx;
  205. margin-bottom: 16rpx;
  206. .title {
  207. height: 48rpx;
  208. align-items: center;
  209. .label {
  210. font-size: 32rpx;
  211. font-weight: bold;
  212. &.code {
  213. margin-left: 8rpx;
  214. }
  215. }
  216. }
  217. }
  218. .item-info {
  219. margin-bottom: 8rpx;
  220. .label {
  221. font-size: 28rpx;
  222. width: 152rpx;
  223. color: #808080;
  224. &.right {
  225. flex: 1;
  226. color: #000000;
  227. }
  228. }
  229. }
  230. .right-info {
  231. justify-content: flex-end;
  232. margin-top: 5rpx;
  233. .label {
  234. font-size: 28rpx;
  235. color: #000000;
  236. &.time {
  237. margin-left: 8rpx;
  238. color: #1684fc;
  239. }
  240. &.number {
  241. margin-left: 8rpx;
  242. color: rgba(0, 226, 166, 1);
  243. }
  244. }
  245. }
  246. }
  247. .bottom {
  248. position: fixed;
  249. right: 0;
  250. bottom: 0;
  251. left: 0;
  252. height: 100rpx;
  253. padding: 16rpx 24rpx;
  254. align-items: center;
  255. background-color: #FFFFFF;
  256. justify-content: space-between;
  257. .bottom-btn {
  258. flex: 1;
  259. font-size: 28rpx;
  260. color: #FFFFFF;
  261. &.left-btn {
  262. background-color: #1684fc;
  263. }
  264. &.right-btn {
  265. background-color: rgb(255, 121, 1);
  266. margin-left: 24rpx;
  267. }
  268. }
  269. }
  270. .status-btn {
  271. width: 100%;
  272. justify-content: flex-end;
  273. .finished-turnover-tag {
  274. margin: unset;
  275. border-radius: 8rpx;
  276. background-color: rgb(255, 85, 85);
  277. font-size: 28rpx;
  278. color: #FFFFFF;
  279. }
  280. }
  281. </style>