consultation.vue 8.6 KB

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