consultation.vue 6.5 KB

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