dialog-end-work.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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" type="number" maxlength="5" v-model="workInfo.qualifiedNum" @input="handleInputQualifiedNum" placeholder="请输入合格量" />
  7. </view>
  8. <view class="list-title uni-row">
  9. <text class="label">废品量</text>
  10. <input class="input" type="number" maxlength="5" v-model="workInfo.rejectNum" placeholder="请输入废品量" />
  11. <!-- <input class="input" type="number" maxlength="5" v-model="workInfo.rejectNum" @input="handleInputRejectNum" placeholder="请输入废品量" /> -->
  12. </view>
  13. <view class="list-title uni-row">
  14. <text class="label">废品原因</text>
  15. <input class="input" v-model="workInfo.reason" placeholder="请输入废品原因" />
  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 open = (data) => {
  51. workInfo.value = data;
  52. console.log(data)
  53. baseDialog.value.open()
  54. }
  55. const emit = defineEmits(['reset'])
  56. function switchChange(event) {
  57. if (event.detail.value) {
  58. workInfo.value.status = "3"
  59. }
  60. }
  61. function handleInputQualifiedNum() {
  62. workInfo.value.qualifiedNum = workInfo.value.qualifiedNum.replace(/^0+|^-|[^\d]/g, '');
  63. }
  64. // function handleInputRejectNum() {
  65. // workInfo.value.rejectNum = workInfo.value.rejectNum.replace(/^0+|^-|[^\d]/g, '');
  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. defineExpose({
  94. open
  95. })
  96. </script>
  97. <style lang="scss">
  98. .dialog-body {
  99. .list-container {
  100. width: 100%;
  101. display: flex;
  102. align-items: flex-start;
  103. padding: 0 4rpx;
  104. .list-title {
  105. width: 100%;
  106. margin-top: 16rpx;
  107. height: 64rpx;
  108. line-height: 64rpx;
  109. .label {
  110. flex: 1;
  111. font-size: 32rpx;
  112. }
  113. .input {
  114. width: 60%;
  115. height: 60rpx;
  116. padding-left: 10rpx;
  117. border-radius: 18rpx;
  118. font-size: 22rpx;
  119. border: 1px solid #808080;
  120. }
  121. }
  122. .switch {
  123. margin-top: -8rpx;
  124. align-items: center;
  125. transform: scale(0.7);
  126. }
  127. .equipment-container {
  128. width: 100%;
  129. height: 120rpx;
  130. flex-wrap: wrap;
  131. justify-content: flex-start;
  132. overflow: auto;
  133. .checkbox {
  134. padding: 12rpx 0;
  135. justify-content: center;
  136. align-items: center;
  137. }
  138. }
  139. .table-item {
  140. margin-top: 24rpx;
  141. }
  142. }
  143. .add-btn-container {
  144. margin-top: 32rpx;
  145. .btn {
  146. flex: 1;
  147. background-color: rgba(255, 85, 85, 1);
  148. color: #FFFFFF;
  149. }
  150. }
  151. }
  152. </style>