consultation.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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-row">
  18. <view class="label">咨询部门</view>
  19. <view class="value" >
  20. <checkbox-group @change="checkboxChange" style="margin-top: 16px;">
  21. <view v-for="(item, index) in consulteList" :key="item.value">
  22. <view class="uni-row checkbox-item" >
  23. <view style="flex-grow: 1;font-size: 16px;">{{item.label}}</view>
  24. <view class="checkboxHidden">
  25. <checkbox :value="item.value" :checked="selected.includes(item.value)" color="#0000ff"
  26. class="checkbox" />
  27. </view>
  28. </view>
  29. <view v-if="index!=consulteList.length -1" class='middle'>
  30. <view class='segment'></view>
  31. <view class='segment'></view>
  32. </view>
  33. </view>
  34. </checkbox-group>
  35. </view>
  36. </view>
  37. <view class="info-row uni-column">
  38. <view class="label" style="margin-bottom: 16rpx;">问题描述</view>
  39. <view class="value uni-row">
  40. <textarea v-model="data.content"></textarea>
  41. </view>
  42. </view>
  43. <view class="info-row">
  44. <view class="label" style="margin-bottom: 16rpx;">照片</view>
  45. <view >
  46. <uni-file-picker :value="photoList.url" @select="select" file-mediatype="image" class="my-files" @delete="handleDeletedPhoto" ></uni-file-picker>
  47. </view>
  48. </view>
  49. <view class="btn uni-row" @click.stop="handleSubmit">提交</view>
  50. </view>
  51. </view>
  52. </template>
  53. <script setup>
  54. import {
  55. ref,
  56. computed
  57. } from 'vue'
  58. import {
  59. onLoad,
  60. onReady,
  61. onUnload,
  62. onShow
  63. } from '@dcloudio/uni-app'
  64. import {
  65. onMounted,
  66. getCurrentInstance
  67. } from 'vue';
  68. import {getURL} from '@/api/sys/user.js'
  69. const dayworkItem = ref({})
  70. const selected = ref([]);
  71. const selectedPhotos = ref([])
  72. const urlList = JSON.parse(uni.getStorageSync('baseUrl'))
  73. const webHost = ref(urlList.pdfAppURL)
  74. const photoList = ref([])
  75. const consulteList = ref([
  76. {
  77. value: 0,
  78. label: "技术"
  79. },
  80. {
  81. value: 1,
  82. label: "品管"
  83. },
  84. ])
  85. const data = ref({
  86. content: '',
  87. departments:null
  88. })
  89. // 创建一个引用来存储最后一次请求的时间戳
  90. const lastRequestTimestamp = ref(0);
  91. onMounted(() => {
  92. const instance = getCurrentInstance().proxy
  93. const eventChannel = instance.getOpenerEventChannel();
  94. eventChannel.on('acceptDataFromOpenerPage', function(data) {
  95. console.log('acceptDataFromOpenerPage', data)
  96. // 传入当前报工信息 通过当前报工的产品和工序获取检查指导书和分选标准
  97. if (data && data.data) {
  98. dayworkItem.value = data.data
  99. }
  100. })
  101. })
  102. // 页面生命周期函数
  103. onLoad(() => {
  104. })
  105. function upLoadImageHandler(arg) {
  106. getURL(arg).then(res =>{
  107. let data = JSON.parse(res)
  108. selectedPhotos.value.push({
  109. url:data.fileName,
  110. pictureName:data.originalFilename
  111. })
  112. console.log(selectedPhotos.value)
  113. })
  114. }
  115. function select (e) {
  116. console.log(e)
  117. const {
  118. tempFilePaths,
  119. tempFiles
  120. } = e
  121. tempFiles.forEach((item,index)=>{
  122. upLoadImageHandler({ filePath: tempFilePaths[index],name:item.name})
  123. })
  124. }
  125. function handleDeletedPhoto(e) {
  126. let fileName = selectedPhotos.value.map(info => info.name)
  127. let index = fileName.findIndex(name => name === e.tempFile.name);
  128. selectedPhotos.value.splice(index,1)
  129. }
  130. //选中咨询部门数据
  131. function checkboxChange(value) {
  132. data.value.departments = value.detail.value; // 添加选中项
  133. }
  134. const handleSubmit = () => {
  135. console.log(selected.value)
  136. console.log(selectedPhotos.value)
  137. console.log(photoList.value)
  138. if (data.value.departments ==null || (data.value.departments !=null &&data.value.departments.length ==0 ) ) {
  139. uni.showToast({
  140. icon: 'none',
  141. title: '请选择咨询部门'
  142. })
  143. return
  144. }
  145. if (data.value.content == null || data.value.content == '') {
  146. uni.showToast({
  147. icon: 'none',
  148. title: '请输入问题描述'
  149. })
  150. return
  151. }
  152. const currentTime = Date.now();
  153. console.log("检查", lastRequestTimestamp);
  154. // 检查是否已经过去了 2 秒
  155. if (currentTime - lastRequestTimestamp.value < 2000) {
  156. // 如果在 2 秒 内已经点击,那么不执行
  157. uni.showToast({
  158. icon: 'none',
  159. title: `请勿重复点击`,
  160. duration: 2000
  161. })
  162. return;
  163. }
  164. uni.$emit('addConsulttationEvent', {
  165. content: data.value.content,
  166. departments: data.value.departments,
  167. pictures: selectedPhotos.value
  168. })
  169. uni.navigateBack()
  170. }
  171. </script>
  172. <style lang="scss">
  173. .page-container {
  174. height: 100%;
  175. background-color: #ececec;
  176. font-size: 28rpx;
  177. padding: 24rpx;
  178. box-sizing: border-box;
  179. }
  180. .consultation-container {
  181. background-color: #ffffff;
  182. padding: 24rpx;
  183. border-radius: 12rpx;
  184. .title {
  185. justify-content: center;
  186. font-size: 32rpx;
  187. font-weight: 700;
  188. }
  189. .info-row {
  190. margin-top: 24rpx;
  191. .label {
  192. width: 160rpx;
  193. }
  194. .value {
  195. flex: 1;
  196. textarea {
  197. flex: 1;
  198. border: 1px solid #888888;
  199. box-sizing: border-box;
  200. padding: 16rpx;
  201. }
  202. }
  203. }
  204. .btn {
  205. background-color: #00D068;
  206. color: #ffffff;
  207. border-radius: 8rpx;
  208. margin: 24rpx;
  209. height: 64rpx;
  210. justify-content: center;
  211. align-items: center;
  212. }
  213. }
  214. .middle {
  215. display: flex;
  216. flex-direction: row;
  217. align-items: center;
  218. justify-content: center
  219. }
  220. .segment {
  221. width: 60%;
  222. background-color: rgba(213, 213, 213, 1);
  223. border: 1rpx solid rgba(213, 213, 213, 1);
  224. margin:8px 0;
  225. }
  226. .checkbox-item {
  227. display: flex;
  228. justify-content: space-between;
  229. align-items: center;
  230. margin-bottom: 10px;
  231. }
  232. .checkbox {
  233. margin-right: 10px;
  234. }
  235. // .uni-file-picker__container{
  236. // }
  237. .my-files {
  238. display: flex;
  239. justify-content: center;
  240. :deep(.uni-file-picker__container) {
  241. flex-direction: row;
  242. }
  243. }
  244. </style>