consultation.vue 3.3 KB

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