dialog-end-work.vue 3.8 KB

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