consultation.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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('firstInpsectionConsultation', function(data) {
  108. console.log('show')
  109. console.log(lot.value)
  110. console.log('firstInpsectionConsultation', 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. if (lot.value.departments == null || (lot.value.departments != null && lot.value.departments.length == 0)) {
  178. uni.showToast({
  179. icon: 'none',
  180. title: '请选择咨询部门'
  181. })
  182. return
  183. }
  184. if (lot.value.departments.includes(0) && (lot.value.product.technicianId == undefined || lot.value.product
  185. .technicianId == 0)) {
  186. uni.showToast({
  187. icon: 'none',
  188. title: '请选择技术负责人'
  189. })
  190. return
  191. }
  192. if (lot.value.question == null || lot.value.question == '') {
  193. uni.showToast({
  194. icon: 'none',
  195. title: '请输入问题描述'
  196. })
  197. return
  198. }
  199. const currentTime = Date.now();
  200. // 检查是否已经过去了 2 秒
  201. if (currentTime - lastRequestTimestamp.value < 2000) {
  202. // 如果在 2 秒 内已经点击,那么不执行
  203. uni.showToast({
  204. icon: 'none',
  205. title: `请勿重复点击`,
  206. duration: 2000
  207. })
  208. return;
  209. }
  210. lastRequestTimestamp.value = currentTime;
  211. store.processInspection = null;
  212. var consultList = []
  213. for (let i = 0; i < lot.value.departments.length; i++) {
  214. let consult = {}
  215. consult.content = lot.value.question
  216. consult.consultDepartment = lot.value.departments[i]
  217. consult.pictures = selectedPhotos.value
  218. consult.technicianId = lot.value.product.technicianId
  219. consultList.push(consult)
  220. }
  221. uni.$emit('addWasteConsultationEvent', consultList)
  222. lot.value = {};
  223. uni.navigateBack()
  224. }
  225. const addTechnician = (data) => {
  226. console.log(data)
  227. lot.value.product.technicianId = data.technicianId
  228. lot.value.product.technicianName = data.technicianName
  229. }
  230. //切换技术负责人
  231. function handleSwitch() {
  232. uni.$on('addTechnicianEvent', (data) => {
  233. addTechnician(data)
  234. })
  235. console.log("777")
  236. uni.navigateTo({
  237. url: "/pages/sorting/technicianOptions"
  238. })
  239. }
  240. </script>
  241. <style lang="scss">
  242. .page-container {
  243. height: 100%;
  244. background-color: #ececec;
  245. font-size: 28rpx;
  246. padding: 24rpx;
  247. box-sizing: border-box;
  248. }
  249. .consultation-container {
  250. background-color: #ffffff;
  251. padding: 24rpx;
  252. border-radius: 12rpx;
  253. .title {
  254. justify-content: center;
  255. font-size: 32rpx;
  256. font-weight: 700;
  257. }
  258. .info-row {
  259. margin-top: 24rpx;
  260. .label {
  261. width: 180rpx;
  262. }
  263. .value {
  264. flex: 1;
  265. textarea {
  266. flex: 1;
  267. border: 1px solid #888888;
  268. box-sizing: border-box;
  269. padding: 16rpx;
  270. }
  271. }
  272. }
  273. .btn {
  274. background-color: #00D068;
  275. color: #ffffff;
  276. border-radius: 8rpx;
  277. margin: 24rpx;
  278. height: 64rpx;
  279. justify-content: center;
  280. align-items: center;
  281. }
  282. }
  283. .middle {
  284. display: flex;
  285. flex-direction: row;
  286. align-items: center;
  287. justify-content: center
  288. }
  289. .segment {
  290. width: 60%;
  291. background-color: rgba(213, 213, 213, 1);
  292. border: 1rpx solid rgba(213, 213, 213, 1);
  293. margin: 8px 0;
  294. }
  295. .checkbox-item {
  296. display: flex;
  297. justify-content: space-between;
  298. align-items: center;
  299. margin-bottom: 10px;
  300. }
  301. .checkbox {
  302. margin-right: 10px;
  303. }
  304. // .uni-file-picker__container{
  305. // }
  306. .my-files {
  307. display: flex;
  308. justify-content: center;
  309. :deep(.uni-file-picker__container) {
  310. flex-direction: row;
  311. }
  312. }
  313. .box-bg {
  314. width: 94%;
  315. padding: 5rpx 16rpx;
  316. justify-content: space-around;
  317. align-items: center;
  318. .input-view {
  319. flex: 1;
  320. height: 60rpx;
  321. border: 1rpx solid #999;
  322. border-radius: 15rpx;
  323. border-top-right-radius: 0;
  324. border-bottom-right-radius: 0;
  325. padding: 0 15rpx;
  326. flex-wrap: nowrap;
  327. line-height: 60rpx;
  328. .input-uni-icon {
  329. line-height: 60rpx;
  330. }
  331. .nav-bar-input {
  332. width: 80%;
  333. height: 60rpx;
  334. line-height: 60rpx;
  335. padding: 0 5rpx;
  336. }
  337. }
  338. .search {
  339. width: 20%;
  340. text-align: center;
  341. background-color: #3e9fff;
  342. height: 60rpx;
  343. border-radius: 15rpx;
  344. border-top-left-radius: 0;
  345. border-bottom-left-radius: 0;
  346. border: 1rpx solid #999;
  347. padding-left: 10px;
  348. }
  349. }
  350. </style>