consultation.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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="box-bg uni-row">
  12. <view class="input-view uni-row">
  13. <input class="nav-bar-input" type="text" disabled="true" v-model="lot.product.technicianName" />
  14. </view>
  15. <view class="search" @click="handleSwitch">
  16. <text style="padding-top: 5px;padding-right: 8px;color: aliceblue;">更换</text>
  17. </view>
  18. </view>
  19. <!-- <view class="value">{{ dayworkItem.technicianName }}</view> -->
  20. </view>
  21. <view class="info-row uni-row">
  22. <view class="label">产品描述</view>
  23. <view class="value">{{ lot.productDescription }}</view>
  24. </view>
  25. <view class="info-row uni-row">
  26. <view class="label">咨询部门</view>
  27. <view class="value">
  28. <checkbox-group @change="checkboxChange" style="margin-top: 16px;">
  29. <view v-for="(item, index) in consulteList" :key="item.value">
  30. <view class="uni-row checkbox-item">
  31. <view style="flex-grow: 1;font-size: 16px;">{{item.label}}</view>
  32. <view class="checkboxHidden">
  33. <checkbox :value="item.value" :checked="selected.includes(item.value)"
  34. color="#0000ff" class="checkbox" />
  35. </view>
  36. </view>
  37. <view v-if="index!=consulteList.length -1" class='middle'>
  38. <view class='segment'></view>
  39. <view class='segment'></view>
  40. </view>
  41. </view>
  42. </checkbox-group>
  43. </view>
  44. </view>
  45. <view class="info-row uni-column">
  46. <view class="label" style="margin-bottom: 16rpx;">问题描述</view>
  47. <view class="value uni-row">
  48. <textarea v-model="lot.question" maxlength="200"></textarea>
  49. </view>
  50. </view>
  51. <view class="info-row">
  52. <view class="label" style="margin-bottom: 16rpx;">照片</view>
  53. <view>
  54. <uni-file-picker :value="photoList.url" @select="select" file-mediatype="image" class="my-files"
  55. @delete="handleDeletedPhoto"></uni-file-picker>
  56. </view>
  57. </view>
  58. <view class="btn uni-row" @click.stop="handleSubmit">提交</view>
  59. </view>
  60. </view>
  61. </template>
  62. <script setup>
  63. import {
  64. ref,
  65. onMounted,
  66. getCurrentInstance
  67. } from 'vue'
  68. import {
  69. onLoad,
  70. onReady,
  71. onUnload,
  72. onShow
  73. } from '@dcloudio/uni-app'
  74. import {
  75. store
  76. } from '@/store/index.js'
  77. import {
  78. getProductConsult
  79. } from '@/api/business/processInspection.js'
  80. import {
  81. getURL
  82. } from '@/api/sys/user.js'
  83. const lot = ref({});
  84. const selected = ref([]);
  85. const selectedPhotos = ref([])
  86. const urlList = JSON.parse(uni.getStorageSync('baseUrl'))
  87. const webHost = ref(urlList.pdfAppURL)
  88. const photoList = ref([])
  89. const consulteList = ref([{
  90. value: 0,
  91. label: "技术"
  92. },
  93. {
  94. value: 1,
  95. label: "品管"
  96. },
  97. ])
  98. // 创建一个引用来存储最后一次请求的时间戳
  99. const lastRequestTimestamp = ref(0);
  100. // 页面生命周期函数
  101. onShow(() => {
  102. uni.$off('addTechnicianEvent');
  103. })
  104. onMounted(() => {
  105. const instance = getCurrentInstance().proxy
  106. const eventChannel = instance.getOpenerEventChannel();
  107. eventChannel.on('onSiteInpsectionConsultation', function(data) {
  108. console.log('show')
  109. console.log(lot.value)
  110. console.log('onSiteInpsectionConsultation', data)
  111. // 传入当前报工信息 通过当前报工的产品和工序获取检查指导书和分选标准
  112. if (data && data.data) {
  113. console.log(data.data)
  114. getProductConsult(data.data).then(res => {
  115. // console.log("res", res);
  116. if (res.code == 200) {
  117. lot.value = data.data
  118. lot.value.product = res.data
  119. lot.value.question = ''
  120. }
  121. })
  122. }
  123. })
  124. })
  125. onLoad(() => {})
  126. function upLoadImageHandler(arg) {
  127. return getURL(arg).then(res => {
  128. let data = JSON.parse(res)
  129. selectedPhotos.value.push({
  130. url: data.fileName,
  131. pictureName: data.originalFilename
  132. })
  133. console.log(selectedPhotos.value)
  134. // uni.showToast({
  135. // icon: 'none',
  136. // title: selectedPhotos.value.length,
  137. // duration: 2000
  138. // })
  139. })
  140. }
  141. function select(e) {
  142. console.log(e)
  143. const {
  144. tempFilePaths,
  145. tempFiles
  146. } = e
  147. uni.showLoading({
  148. title: '图片上传中',
  149. mask: true
  150. });
  151. // 创建一个空的Promise数组
  152. let uploadPromises = tempFiles.map((item, index) => {
  153. return upLoadImageHandler({
  154. filePath: tempFilePaths[index],
  155. name: item.name
  156. });
  157. });
  158. // 使用Promise.all等待所有图片上传完成
  159. Promise.all(uploadPromises).then(() => {
  160. // 上传完成后关闭加载提示
  161. uni.hideLoading();
  162. }).catch(() => {
  163. // 如果有错误发生,也关闭加载提示
  164. uni.hideLoading();
  165. });
  166. }
  167. function handleDeletedPhoto(e) {
  168. let fileName = selectedPhotos.value.map(info => info.name)
  169. let index = fileName.findIndex(name => name === e.tempFile.name);
  170. selectedPhotos.value.splice(index, 1)
  171. }
  172. //选中咨询部门数据
  173. function checkboxChange(value) {
  174. lot.value.departments = value.detail.value;
  175. }
  176. const handleSubmit = () => {
  177. console.log(lot.value.product)
  178. if (lot.value.departments == null || (lot.value.departments != null && lot.value.departments.length == 0)) {
  179. uni.showToast({
  180. icon: 'none',
  181. title: '请选择咨询部门'
  182. })
  183. return
  184. }
  185. if (lot.value.departments.includes(0) && (lot.value.product.technicianId == undefined || lot.value.product
  186. .technicianId == 0)) {
  187. uni.showToast({
  188. icon: 'none',
  189. title: '请选择技术负责人'
  190. })
  191. return
  192. }
  193. if (lot.value.question == null || lot.value.question == '') {
  194. uni.showToast({
  195. icon: 'none',
  196. title: '请输入问题描述'
  197. })
  198. return
  199. }
  200. const currentTime = Date.now();
  201. // 检查是否已经过去了 2 秒
  202. if (currentTime - lastRequestTimestamp.value < 2000) {
  203. // 如果在 2 秒 内已经点击,那么不执行
  204. uni.showToast({
  205. icon: 'none',
  206. title: `请勿重复点击`,
  207. duration: 2000
  208. })
  209. return;
  210. }
  211. lastRequestTimestamp.value = currentTime;
  212. store.processInspection = null;
  213. var consultList = []
  214. for (let i = 0; i < lot.value.departments.length; i++) {
  215. let consult = {}
  216. consult.content = lot.value.question
  217. consult.consultDepartment = lot.value.departments[i]
  218. consult.pictures = selectedPhotos.value
  219. consult.technicianId = lot.value.product.technicianId
  220. consultList.push(consult)
  221. }
  222. uni.$emit('addWasteConsultationEvent', consultList)
  223. // lot.value = {};
  224. uni.navigateBack()
  225. }
  226. const addTechnician = (data) => {
  227. console.log(data)
  228. lot.value.product.technicianId = data.technicianId
  229. lot.value.product.technicianName = data.technicianName
  230. }
  231. //切换技术负责人
  232. function handleSwitch() {
  233. uni.$on('addTechnicianEvent', (data) => {
  234. addTechnician(data)
  235. })
  236. console.log("777")
  237. uni.navigateTo({
  238. url: "/pages/sorting/technicianOptions"
  239. })
  240. }
  241. </script>
  242. <style lang="scss">
  243. .page-container {
  244. height: 100%;
  245. background-color: #ececec;
  246. font-size: 28rpx;
  247. padding: 24rpx;
  248. box-sizing: border-box;
  249. }
  250. .consultation-container {
  251. background-color: #ffffff;
  252. padding: 24rpx;
  253. border-radius: 12rpx;
  254. .title {
  255. justify-content: center;
  256. font-size: 32rpx;
  257. font-weight: 700;
  258. }
  259. .info-row {
  260. margin-top: 24rpx;
  261. .label {
  262. width: 180rpx;
  263. }
  264. .value {
  265. flex: 1;
  266. textarea {
  267. flex: 1;
  268. border: 1px solid #888888;
  269. box-sizing: border-box;
  270. padding: 16rpx;
  271. }
  272. }
  273. }
  274. .btn {
  275. background-color: #00D068;
  276. color: #ffffff;
  277. border-radius: 8rpx;
  278. margin: 24rpx;
  279. height: 64rpx;
  280. justify-content: center;
  281. align-items: center;
  282. }
  283. }
  284. .middle {
  285. display: flex;
  286. flex-direction: row;
  287. align-items: center;
  288. justify-content: center
  289. }
  290. .segment {
  291. width: 60%;
  292. background-color: rgba(213, 213, 213, 1);
  293. border: 1rpx solid rgba(213, 213, 213, 1);
  294. margin: 8px 0;
  295. }
  296. .checkbox-item {
  297. display: flex;
  298. justify-content: space-between;
  299. align-items: center;
  300. margin-bottom: 10px;
  301. }
  302. .checkbox {
  303. margin-right: 10px;
  304. }
  305. // .uni-file-picker__container{
  306. // }
  307. .my-files {
  308. display: flex;
  309. justify-content: center;
  310. :deep(.uni-file-picker__container) {
  311. flex-direction: row;
  312. }
  313. }
  314. .box-bg {
  315. width: 94%;
  316. padding: 5rpx 16rpx;
  317. justify-content: space-around;
  318. align-items: center;
  319. .input-view {
  320. flex: 1;
  321. height: 60rpx;
  322. border: 1rpx solid #999;
  323. border-radius: 15rpx;
  324. border-top-right-radius: 0;
  325. border-bottom-right-radius: 0;
  326. padding: 0 15rpx;
  327. flex-wrap: nowrap;
  328. line-height: 60rpx;
  329. .input-uni-icon {
  330. line-height: 60rpx;
  331. }
  332. .nav-bar-input {
  333. width: 80%;
  334. height: 60rpx;
  335. line-height: 60rpx;
  336. padding: 0 5rpx;
  337. }
  338. }
  339. .search {
  340. width: 20%;
  341. text-align: center;
  342. background-color: #3e9fff;
  343. height: 60rpx;
  344. border-radius: 15rpx;
  345. border-top-left-radius: 0;
  346. border-bottom-left-radius: 0;
  347. border: 1rpx solid #999;
  348. padding-left: 10px;
  349. }
  350. }
  351. </style>