consultation.vue 3.1 KB

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