dialog-end-work.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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" v-model="workInfo.qualifiedNum" placeholder="请输入合格量" />
  7. </view>
  8. <view class="list-title uni-row">
  9. <text class="label">废品量</text>
  10. <input class="input" v-model="workInfo.rejectNum" 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 checkboxChange(event) {
  61. // console.log(event.detail.value)
  62. // workInfo.value.equiments = event.detail.value
  63. // }
  64. function handleFinishReporting() {
  65. console.log(workInfo.value)
  66. if (workInfo.value.status != '3') {
  67. workInfo.value.status = '2';
  68. }
  69. workInfo.value.endTime = timestampToTime(new Date());
  70. console.log(workInfo.value)
  71. saveDayWorkItem(workInfo.value).then(res => {
  72. if (res.code === 200) {
  73. uni.showToast({
  74. icon: 'success',
  75. title: '操作成功',
  76. duration: 2000
  77. });
  78. emit('reset');
  79. uni.$emit('dayworkItemUpdate');
  80. baseDialog.value.close();
  81. } else {
  82. uni.showToast({
  83. icon: 'error',
  84. title: '操作失败',
  85. duration: 2000
  86. });
  87. }
  88. })
  89. }
  90. defineExpose({
  91. open
  92. })
  93. </script>
  94. <style lang="scss">
  95. .dialog-body {
  96. .list-container {
  97. width: 100%;
  98. display: flex;
  99. align-items: flex-start;
  100. padding: 0 4rpx;
  101. .list-title {
  102. width: 100%;
  103. margin-top: 16rpx;
  104. height: 64rpx;
  105. line-height: 64rpx;
  106. .label {
  107. flex: 1;
  108. font-size: 32rpx;
  109. }
  110. .input {
  111. width: 60%;
  112. height: 60rpx;
  113. padding-left: 10rpx;
  114. border-radius: 18rpx;
  115. font-size: 22rpx;
  116. border: 1px solid #808080;
  117. }
  118. }
  119. .switch {
  120. margin-top: -8rpx;
  121. align-items: center;
  122. transform: scale(0.7);
  123. }
  124. .equipment-container {
  125. width: 100%;
  126. height: 120rpx;
  127. flex-wrap: wrap;
  128. justify-content: flex-start;
  129. overflow: auto;
  130. .checkbox {
  131. padding: 12rpx 0;
  132. justify-content: center;
  133. align-items: center;
  134. }
  135. }
  136. .table-item {
  137. margin-top: 24rpx;
  138. }
  139. }
  140. .add-btn-container {
  141. margin-top: 32rpx;
  142. .btn {
  143. flex: 1;
  144. background-color: rgba(255, 85, 85, 1);
  145. color: #FFFFFF;
  146. }
  147. }
  148. }
  149. </style>