dialog-end-work.vue 4.4 KB

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