consultation.vue 8.1 KB

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