consultation.vue 8.4 KB

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