dialog-end-work.vue 4.0 KB

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