consultation.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view class="page-container uni-column">
  3. <view class="consultation-container uni-column">
  4. <view class="title uni-row">咨询</view>
  5. <view class="info-row uni-row">
  6. <view class="label">批次号</view>
  7. <view class="value">{{ lot.lotCode }}</view>
  8. </view>
  9. <view class="info-row uni-row">
  10. <view class="label">技术负责人</view>
  11. <view class="value">{{ lot.product.technicianName }}</view>
  12. </view>
  13. <view class="info-row uni-row">
  14. <view class="label">产品描述</view>
  15. <view class="value">{{ lot.productDescription }}</view>
  16. </view>
  17. <view class="info-row uni-column">
  18. <view class="label" style="margin-bottom: 16rpx;">问题描述</view>
  19. <view class="value uni-row">
  20. <textarea v-model="lot.question"></textarea>
  21. </view>
  22. </view>
  23. <view class="btn uni-row" @click.stop="handleSubmit">提交</view>
  24. </view>
  25. </view>
  26. </template>
  27. <script setup>
  28. import {
  29. ref,
  30. onMounted,
  31. getCurrentInstance
  32. } from 'vue'
  33. import {
  34. onLoad,
  35. onReady,
  36. onUnload,
  37. onShow
  38. } from '@dcloudio/uni-app'
  39. import {
  40. store
  41. } from '@/store/index.js'
  42. import {
  43. getProductConsult
  44. } from '@/api/business/processInspection.js'
  45. const lot = ref({});
  46. // 创建一个引用来存储最后一次请求的时间戳
  47. const lastRequestTimestamp = ref(0);
  48. const daywork = ref({
  49. lot_code: 'D35400554012',
  50. product_description: '电机-254.364.14552',
  51. question: ''
  52. })
  53. // 页面生命周期函数
  54. onMounted(() => {
  55. console.log("咨询页面打开");
  56. const instance = getCurrentInstance().proxy
  57. const eventChannel = instance.getOpenerEventChannel();
  58. eventChannel.on('processInspectionConsultation', function(data) {
  59. console.log('processInspectionConsultation', data)
  60. // 传入当前报工信息 通过当前报工的产品和工序获取检查指导书和分选标准
  61. if (data && data.data) {
  62. getProductConsult(data.data).then(res => {
  63. console.log("res", res);
  64. if (res.code == 200) {
  65. lot.value = data.data
  66. lot.value.product = res.data
  67. }
  68. })
  69. }
  70. })
  71. })
  72. onLoad(() => {
  73. })
  74. const handleSubmit = () => {
  75. if (lot.value.question == null || lot.value.question == '') {
  76. uni.showToast({
  77. icon: 'none',
  78. title: '请输入问题描述'
  79. })
  80. return
  81. }
  82. const currentTime = Date.now();
  83. // 检查是否已经过去了 2 秒
  84. if (currentTime - lastRequestTimestamp.value < 2000) {
  85. // 如果在 2 秒 内已经点击,那么不执行
  86. uni.showToast({
  87. icon: 'none',
  88. title: `请勿重复点击`,
  89. duration: 2000
  90. })
  91. return;
  92. }
  93. store.processInspection = null;
  94. uni.$emit('addWasteConsultationEvent', {
  95. question: lot.value.question
  96. })
  97. uni.navigateBack()
  98. }
  99. </script>
  100. <style lang="scss">
  101. .page-container {
  102. height: 100%;
  103. background-color: #ececec;
  104. font-size: 28rpx;
  105. padding: 24rpx;
  106. box-sizing: border-box;
  107. }
  108. .consultation-container {
  109. background-color: #ffffff;
  110. padding: 24rpx;
  111. border-radius: 12rpx;
  112. .title {
  113. justify-content: center;
  114. font-size: 32rpx;
  115. font-weight: 700;
  116. }
  117. .info-row {
  118. margin-top: 24rpx;
  119. .label {
  120. width: 160rpx;
  121. }
  122. .value {
  123. flex: 1;
  124. textarea {
  125. flex: 1;
  126. border: 1px solid #888888;
  127. box-sizing: border-box;
  128. padding: 16rpx;
  129. }
  130. }
  131. }
  132. .btn {
  133. background-color: #00D068;
  134. color: #ffffff;
  135. border-radius: 8rpx;
  136. margin: 24rpx;
  137. height: 64rpx;
  138. justify-content: center;
  139. align-items: center;
  140. }
  141. }
  142. </style>