consultation.vue 8.4 KB

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