dialog-end-work.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <dialog-base ref="baseDialog" title="结束报工">
  3. <view class="list-container">
  4. <view class="list-title uni-row">
  5. <text class="label">合格量</text>
  6. <input class="input" style="width: 70%;" v-model="workInfo.qualifiedNum" placeholder="请输入合格量" />
  7. </view>
  8. <view class="list-title uni-row">
  9. <text class="label">废品信息</text>
  10. <view class="uni-row" style="justify-content: flex-end;"><text class="label" style="color: blue;" @click="handleAddWasteInfo">+添加</text></view>
  11. </view>
  12. <view class="list-title uni-row" v-for="(item, index) in wasteInfo">
  13. <input class="input" style="width: 20%;" v-model="item.rejectNum" placeholder="废品量" />
  14. <input class="input" style="margin-left: 24rpx;width: 70%;" v-model="item.reason" placeholder="请输入废品原因" />
  15. <uni-icons class="icon-gear" type="close" size="60" color="red" @click="handleDeleteWasteInfo(index)"></uni-icons>
  16. </view>
  17. <view class="list-title uni-row" style="margin-top: 48rpx;">
  18. <text class="label">当前序是否完成</text><text>否</text>
  19. <switch class="switch" @change="switchChange" color="rgba(255,85,85,1)" />
  20. <text>是</text>
  21. </view>
  22. <!-- <view class="list-title"><text class="label">请选择设备:</text></view> -->
  23. <!-- <scroll-view class="scroll-container" scroll-y> -->
  24. <!-- <checkbox-group class="equipment-container uni-row" @change="checkboxChange">
  25. <checkbox v-for="(item,index) in equiments" class="checkbox" style="transform:scale(0.8)" :key="index"
  26. :value="item" :checked="item.checked">
  27. {{item}}
  28. </checkbox>
  29. </checkbox-group> -->
  30. </view>
  31. <view class="add-btn-container uni-row">
  32. <button type="default" class="btn" @click="handleFinishReporting">结束报工</button>
  33. </view>
  34. </dialog-base>
  35. </template>
  36. <script setup>
  37. import {
  38. ref,
  39. getCurrentInstance
  40. } from 'vue'
  41. import {
  42. updateDayWorkItem,
  43. saveDayWorkItem
  44. } from "@/api/business/dayWorkItem.js"
  45. import {
  46. timestampToTime
  47. } from '@/utils/common.js'
  48. const baseDialog = ref(null)
  49. const workInfo = ref({})
  50. const wasteInfo = ref([])
  51. const open = (data) => {
  52. workInfo.value = data;
  53. console.log(data)
  54. wasteInfo.value =[]
  55. baseDialog.value.open()
  56. }
  57. const emit = defineEmits(['reset'])
  58. function switchChange(event) {
  59. if (event.detail.value) {
  60. workInfo.value.status = "3"
  61. }
  62. }
  63. // function checkboxChange(event) {
  64. // console.log(event.detail.value)
  65. // workInfo.value.equiments = event.detail.value
  66. // }
  67. function handleFinishReporting() {
  68. console.log(workInfo.value)
  69. if (workInfo.value.status != '3') {
  70. workInfo.value.status = '2';
  71. }
  72. workInfo.value.endTime = timestampToTime(new Date());
  73. console.log(workInfo.value)
  74. saveDayWorkItem(workInfo.value).then(res => {
  75. if (res.code === 200) {
  76. uni.showToast({
  77. icon: 'success',
  78. title: '操作成功',
  79. duration: 2000
  80. });
  81. emit('reset');
  82. uni.$emit('dayworkItemUpdate');
  83. baseDialog.value.close();
  84. } else {
  85. uni.showToast({
  86. icon: 'error',
  87. title: '操作失败',
  88. duration: 2000
  89. });
  90. }
  91. })
  92. }
  93. function handleAddWasteInfo() {
  94. wasteInfo.value.push({ rejectNum: '', reason: '' })
  95. }
  96. function handleDeleteWasteInfo(index) {
  97. wasteInfo.value.splice(index,1)
  98. }
  99. defineExpose({
  100. open
  101. })
  102. </script>
  103. <style lang="scss">
  104. .dialog-body {
  105. .list-container {
  106. width: 100%;
  107. display: flex;
  108. align-items: flex-start;
  109. padding: 0 4rpx;
  110. .list-title {
  111. width: 100%;
  112. margin-top: 16rpx;
  113. height: 64rpx;
  114. line-height: 64rpx;
  115. .label {
  116. flex: 1;
  117. font-size: 32rpx;
  118. }
  119. .input {
  120. width: 40%;
  121. height: 60rpx;
  122. padding-left: 10rpx;
  123. font-size: 22rpx;
  124. border: 1px solid #808080;
  125. }
  126. .icon-gear {
  127. font-size: 56rpx;
  128. }
  129. }
  130. .switch {
  131. margin-top: -8rpx;
  132. align-items: center;
  133. transform: scale(0.7);
  134. }
  135. .equipment-container {
  136. width: 100%;
  137. height: 120rpx;
  138. flex-wrap: wrap;
  139. justify-content: flex-start;
  140. overflow: auto;
  141. .checkbox {
  142. padding: 12rpx 0;
  143. justify-content: center;
  144. align-items: center;
  145. }
  146. }
  147. .table-item {
  148. margin-top: 24rpx;
  149. }
  150. }
  151. .add-btn-container {
  152. margin-top: 32rpx;
  153. .btn {
  154. flex: 1;
  155. background-color: rgba(255, 85, 85, 1);
  156. color: #FFFFFF;
  157. }
  158. }
  159. }
  160. </style>