consultation.vue 3.4 KB

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