dialog-end-work.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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 handleInputQualifiedNum() {
  64. workInfo.value.qualifiedNum = workInfo.value.qualifiedNum.replace(/^0+|^-|[^\d]/g, '');
  65. }
  66. // function handleInputRejectNum() {
  67. // workInfo.value.rejectNum = workInfo.value.rejectNum.replace(/^0+|^-|[^\d]/g, '');
  68. // }
  69. function handleFinishReporting() {
  70. console.log(workInfo.value)
  71. if (workInfo.value.status != '3') {
  72. workInfo.value.status = '2';
  73. }
  74. workInfo.value.endTime = timestampToTime(new Date());
  75. console.log(workInfo.value)
  76. saveDayWorkItem(workInfo.value).then(res => {
  77. if (res.code === 200) {
  78. uni.showToast({
  79. icon: 'success',
  80. title: '操作成功',
  81. duration: 2000
  82. });
  83. emit('reset');
  84. uni.$emit('dayworkItemUpdate');
  85. baseDialog.value.close();
  86. } else {
  87. uni.showToast({
  88. icon: 'error',
  89. title: '操作失败',
  90. duration: 2000
  91. });
  92. }
  93. })
  94. }
  95. function handleAddWasteInfo() {
  96. wasteInfo.value.push({ rejectNum: '', reason: '' })
  97. }
  98. function handleDeleteWasteInfo(index) {
  99. wasteInfo.value.splice(index,1)
  100. }
  101. defineExpose({
  102. open
  103. })
  104. </script>
  105. <style lang="scss">
  106. .dialog-body {
  107. .list-container {
  108. width: 100%;
  109. display: flex;
  110. align-items: flex-start;
  111. padding: 0 4rpx;
  112. .list-title {
  113. width: 100%;
  114. margin-top: 16rpx;
  115. height: 64rpx;
  116. line-height: 64rpx;
  117. .label {
  118. flex: 1;
  119. font-size: 32rpx;
  120. }
  121. .input {
  122. width: 40%;
  123. height: 60rpx;
  124. padding-left: 10rpx;
  125. font-size: 22rpx;
  126. border: 1px solid #808080;
  127. }
  128. .icon-gear {
  129. font-size: 56rpx;
  130. }
  131. }
  132. .switch {
  133. margin-top: -8rpx;
  134. align-items: center;
  135. transform: scale(0.7);
  136. }
  137. .equipment-container {
  138. width: 100%;
  139. height: 120rpx;
  140. flex-wrap: wrap;
  141. justify-content: flex-start;
  142. overflow: auto;
  143. .checkbox {
  144. padding: 12rpx 0;
  145. justify-content: center;
  146. align-items: center;
  147. }
  148. }
  149. .table-item {
  150. margin-top: 24rpx;
  151. }
  152. }
  153. .add-btn-container {
  154. margin-top: 32rpx;
  155. .btn {
  156. flex: 1;
  157. background-color: rgba(255, 85, 85, 1);
  158. color: #FFFFFF;
  159. }
  160. }
  161. }
  162. </style>