inspectAdd.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. <!-- 开始检查 -->
  2. <template>
  3. <view class="inspectAdd">
  4. <scroll-view scroll-y @scrolltolower="scrollGet" class="info-max-box">
  5. <view class="tip">第一次检查</view>
  6. <view class="items">
  7. <view class="items-t">
  8. <view class="items-t-r">{{newData.data3}}</view>
  9. </view>
  10. <view class="items-b">< {{newData.data4}} <</view>
  11. </view>
  12. <view class="items-number">此检查项在当前实验室累计出现<text>{{newData.data5}}</text>次隐患</view>
  13. <view class="list">
  14. <view class="list-li">
  15. <view>检查要点</view>
  16. <view>
  17. <img src="@/pages_safetyCheck/images/icon_06.png">
  18. </view>
  19. </view>
  20. <view class="hidden-content">{{newData.data6}}
  21. </view>
  22. <view class="list-li">
  23. <view>检查隐患</view>
  24. <view>
  25. <img src="@/pages_safetyCheck/images/icon_06.png">
  26. </view>
  27. </view>
  28. <textarea class="describe" type="text" v-model="form.rectifyDescribe" maxlength="200"
  29. placeholder="请填写隐患描述" placeholder-style="font-size:24rpx;color:#999;"></textarea>
  30. <view class="check-for-img-max-box">
  31. <view class="left-title-p"></view>
  32. <view class="right-img-box">
  33. <view class="img-box" v-for="(imgUrl,imgIndex) in form.imgDtoList" :key="imgIndex">
  34. <img class="img-data" :src="baseUrl+imgUrl.fileUrl">
  35. <img class="position-img" src="@/pages_safetyCheck/images/icon_ssp_closure.png"
  36. @click="delImg(imgIndex)">
  37. </view>
  38. <img class="add-button" src="@/pages_safetyCheck/images/img_ssp_pz@1x.png"
  39. @click="selectImage()" v-if="form.imgDtoList.length<5">
  40. </view>
  41. </view>
  42. </view>
  43. <view class="voice">
  44. <view class="voice_t">
  45. <view class="voice_t_l">语音备注:(选填)</view>
  46. <!-- <img class="voice_t_r" src="@/pages_safetyExamine/images/icon_ksjc_yysr.png"
  47. @longpress.stop="recordButton(item,$event)" @touchmove.stop="cancelButton"
  48. @touchend.stop="sendButton(item,$event)"> -->
  49. </view>
  50. <view class="voice_b" v-for="(voiceItem,voiceIndex) in voiceList" :key="voiceIndex">
  51. <view class="voice_b_l" @tap="voicePlay(voiceItem.url)">
  52. <img class="add-button" src="@/pages_safetyCheck/images//icon_yybz_yy.png" />
  53. {{voiceItem.times}}″
  54. </view>
  55. <img class="voice_b_r" src="@/pages_safetyCheck/images/icon_yybz_sc.png"
  56. @tap="voiceDele('',voiceIndex)" />
  57. </view>
  58. <view class="voice-btn">
  59. <img class="voice_t_r" src="@/pages_safetyCheck/images/icon_sskz_azsh.png"
  60. @longpress.stop="recordButton(item,$event)" @touchmove.stop="cancelButton"
  61. @touchend.stop="sendButton(item,$event)" />
  62. <text>按住说话</text>
  63. </view>
  64. </view>
  65. </scroll-view>
  66. <view class="sub-btn">
  67. <view>保存草稿</view>
  68. <view>符合</view>
  69. <view>不符合</view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import {
  75. config
  76. } from '@/api/request/config.js'
  77. export default {
  78. name: "inspectAdd",
  79. components: {
  80. },
  81. data() {
  82. return {
  83. baseUrl: config.base_url,
  84. form: {
  85. imgDtoList: [],
  86. },
  87. newData: {
  88. data1: '实验室名称(房间号)',
  89. data2: '学院单位名称',
  90. data3: '1.1.1 检查项检查项检查项检查',
  91. data4: '1.1 检查项检查项检查项检查项检查项检查项',
  92. data5: '19',
  93. data6: '(1)有学校相关会议(校务会议、党委常委会会议等)纪要,内容包含实验室安全工作。',
  94. data7: '内容内容内容内容内容内容内容内容内容内容内容内内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容',
  95. data8: '李瑶瑶',
  96. data9: '2024-01-01',
  97. data10: '计划标题计划标题计划标题计划标题计划标题计标题计划标题计划标题',
  98. data11: ['校级检查', '全面检查', '交叉检查'],
  99. rectificationStatus: 0, //整改状态 0待整改 1暂无法整改 2已整改
  100. },
  101. voiceList: [{
  102. 'times': '10',
  103. 'url': '2312312'
  104. }, ],
  105. }
  106. },
  107. onLoad(option) {
  108. //this.$set(this, 'newData', JSON.parse(decodeURIComponent(option.infoData)));
  109. },
  110. onShow() {
  111. },
  112. mounted() {
  113. },
  114. methods: {
  115. //滚动事件
  116. scrollGet() {},
  117. /******图片上传******/
  118. selectImage() {
  119. let self = this;
  120. if (this.form.imgDtoList.length > 4) {
  121. uni.showToast({
  122. title: '最多上传5张图片',
  123. icon: "none",
  124. mask: true,
  125. duration: 2000
  126. });
  127. return
  128. }
  129. wx.chooseImage({
  130. count: 1,
  131. sizeType: ["original", "compressed"],
  132. sourceType: ["album", "camera"],
  133. success: function(res) {
  134. let tempFilePaths = res.tempFilePaths[0];
  135. self.uploadImg(tempFilePaths);
  136. }
  137. });
  138. },
  139. async uploadImg(tempFilePaths) {
  140. var self = this;
  141. uni.showLoading({
  142. title: '上传中',
  143. mask: true
  144. });
  145. uni.uploadFile({
  146. url: config.base_url + '/system/file/upload', //仅为示例,非真实的接口地址
  147. header: {
  148. 'Authorization': uni.getStorageSync('token')
  149. },
  150. filePath: tempFilePaths,
  151. name: 'file',
  152. formData: {
  153. 'user': 'test'
  154. },
  155. success: (uploadFileRes) => {
  156. let res = JSON.parse(uploadFileRes.data);
  157. if (res.code == 200) {
  158. this.form.imgDtoList.push({
  159. 'fileUrl': res.data.url,
  160. 'fileName': res.data.name
  161. });
  162. console.log(res.data.url)
  163. } else {
  164. uni.showToast({
  165. title: res.msg,
  166. icon: "none",
  167. mask: true,
  168. duration: 2000
  169. });
  170. }
  171. },
  172. fail: err => {},
  173. complete: () => {
  174. uni.hideLoading()
  175. }
  176. });
  177. },
  178. //删除图片
  179. delImg(minIndex) {
  180. this.form.imgDtoList.splice(minIndex, 1);
  181. this.$forceUpdate();
  182. },
  183. /******语音备注 *******/
  184. //语音备忘播放
  185. async voicePlay(item) {
  186. myaudio.src = config.base_url + item;
  187. myaudio.play();
  188. },
  189. //语音备忘删除
  190. async voiceDele(item, voiceIndex) {
  191. let self = this;
  192. uni.showModal({
  193. title: '',
  194. cancelColor: '#999999',
  195. confirmColor: '#FF6E6E',
  196. content: '确定删除此语音吗?',
  197. success(res) {
  198. if (res.confirm) {
  199. console.log('用户点击确定')
  200. this.voiceList.splice(voiceIndex, 1);
  201. self.$forceUpdate();
  202. } else if (res.cancel) {
  203. console.log('用户点击取消')
  204. }
  205. }
  206. })
  207. },
  208. //录制
  209. recordButton(item, e) {
  210. console.log("按下")
  211. let self = this;
  212. if (this.voiceList.length >= 5) {
  213. uni.showToast({
  214. title: '语音备忘最多只能上传5条',
  215. icon: "none",
  216. mask: true,
  217. duration: 2000
  218. });
  219. return
  220. }
  221. this.liveType = true;
  222. console.log('录制', e)
  223. this.startPoint = e.touches[0]; //记录长按时开始点信息,后面用于计算上划取消时手指滑动的距离。
  224. const options = {
  225. duration: 60000,
  226. sampleRate: 16000,
  227. numberOfChannels: 1,
  228. encodeBitRate: 48000,
  229. format: 'mp3',
  230. frameSize: 50
  231. }
  232. this.recorderManager.start(options); //开始录音
  233. this.recorderManager.onStart(() => {
  234. console.log('recorder start')
  235. })
  236. this.recorderManager.onError((res) => {
  237. console.log(res);
  238. })
  239. wx.showToast({
  240. title: "正在录音,上划取消发送",
  241. icon: "none",
  242. duration: 60000 //先定义个60秒,后面可以手动调用wx.hideToast()隐藏
  243. });
  244. this.sendLock = false; //长按时是不上锁的。
  245. },
  246. //取消
  247. cancelButton(e) {
  248. console.log("移动")
  249. let self = this;
  250. this.liveType = false;
  251. console.log('取消', e)
  252. let moveLenght = e.touches[e.touches.length - 1].clientY - this.startPoint.clientY; //移动距离
  253. if (Math.abs(moveLenght) > 50) {
  254. wx.showToast({
  255. title: "松开手指,取消发送",
  256. icon: "none",
  257. duration: 60000
  258. });
  259. this.sendLock = true; //触发了上滑取消发送,上锁
  260. } else {
  261. wx.showToast({
  262. title: "正在录音,上划取消发送",
  263. icon: "none",
  264. duration: 60000
  265. });
  266. this.sendLock = false; //上划距离不足,依然可以发送,不上锁
  267. }
  268. },
  269. //发送
  270. sendButton(item, e) {
  271. console.log("松开")
  272. let self = this;
  273. this.liveType = false;
  274. console.log('发送', e)
  275. wx.hideToast(); //结束录音、隐藏Toast提示框
  276. this.recorderManager.stop(); //结束录音
  277. this.recorderManager.onStop((res) => {
  278. if (!this.sendLock) {
  279. this.uploadVoice(item, res.duration, res.tempFilePath);
  280. }
  281. console.log('停止录音', res.tempFilePath)
  282. console.log("sendLock", this.sendLock);
  283. })
  284. },
  285. //上传MP3
  286. async uploadVoice(item, times, tempFilePaths) {
  287. console.log(item)
  288. console.log(times)
  289. console.log(tempFilePaths)
  290. var self = this;
  291. uni.uploadFile({
  292. url: config.base_url + '/system/file/upload', //仅为示例,非真实的接口地址
  293. header: {
  294. 'Authorization': uni.getStorageSync('token')
  295. },
  296. filePath: tempFilePaths,
  297. name: 'file',
  298. formData: {
  299. 'user': 'test'
  300. },
  301. success: (uploadFileRes) => {
  302. let res = JSON.parse(uploadFileRes.data);
  303. if (res.code == 200) {
  304. console.log("上传成功", res)
  305. console.log(item)
  306. let seconds = Math.round((parseInt(times) % (1000 * 60)) / 1000);
  307. this.voiceList.push({
  308. 'times': seconds,
  309. 'url': res.data.url
  310. })
  311. console.log(JSON.stringify(self.voice))
  312. //self.textParseUrlIps(res.data.url);
  313. // self.newData.imgList.push(res.data.url);
  314. } else {
  315. uni.showToast({
  316. title: res.msg,
  317. icon: "none",
  318. mask: true,
  319. duration: 2000
  320. });
  321. }
  322. },
  323. fail: err => {
  324. uni.hideLoading()
  325. },
  326. complete: () => {}
  327. });
  328. },
  329. }
  330. }
  331. </script>
  332. <style lang="stylus" scoped>
  333. .inspectAdd {
  334. height: 100%;
  335. display flex;
  336. box-sizing: border-box;
  337. padding-bottom: 160rpx;
  338. box-sizing: border-box;
  339. #bgColor-A {
  340. color: #FFD400;
  341. }
  342. #bgColor-B {
  343. color: #FF8C00;
  344. }
  345. #bgColor-C {
  346. color: #E11608;
  347. }
  348. .tip {
  349. width: 750rpx;
  350. height: 80rpx;
  351. background: rgba(1, 131, 250, 0.2);
  352. font-weight: normal;
  353. font-size: 28rpx;
  354. color: #0183FA;
  355. line-height: 80rpx;
  356. text-align: center;
  357. }
  358. .items {
  359. width: 690rpx;
  360. min-height: 165rpx;
  361. background: #FFFFFF;
  362. border-radius: 20rpx 20rpx 20rpx 20rpx;
  363. margin: 20rpx 0 0 30rpx;
  364. .items-li {
  365. display: flex;
  366. justify-content: space-between;
  367. align-items: center;
  368. padding: 0 30rpx;
  369. box-sizing: border-box;
  370. border-bottom: 1rpx solid #E0E0E0;
  371. >view:nth-of-type(1) {
  372. font-size: 30rpx;
  373. color: #333333;
  374. line-height: 80rpx;
  375. text-align: left;
  376. }
  377. >view:nth-of-type(2) {
  378. font-size: 28rpx;
  379. color: #666666;
  380. line-height: 80rpx;
  381. text-align: left;
  382. display: flex;
  383. justify-content: space-between;
  384. align-items: center;
  385. }
  386. }
  387. .items-t {
  388. border-bottom: 1rpx solid #E0E0E0;
  389. height: 80rpx;
  390. display: flex;
  391. justify-content: flex-start;
  392. align-items: center;
  393. padding: 0 30rpx;
  394. box-sizing: border-box;
  395. .items-t-l {
  396. width: 175rpx;
  397. height: 50rpx;
  398. background: #E11608;
  399. border-radius: 50rpx 50rpx 50rpx 50rpx;
  400. font-size: 30rpx;
  401. color: #FFFFFF;
  402. line-height: 50rpx;
  403. text-align: center;
  404. margin-right: 14rpx;
  405. }
  406. .items-t-r {
  407. font-size: 30rpx;
  408. color: #333333;
  409. line-height: 42rpx;
  410. text-align: left;
  411. }
  412. }
  413. .items-b {
  414. padding: 0 30rpx;
  415. box-sizing: border-box;
  416. height: 80rpx;
  417. font-size: 28rpx;
  418. color: #666666;
  419. line-height: 80rpx;
  420. text-align: left;
  421. }
  422. }
  423. .items-number {
  424. font-size: 24rpx;
  425. color: #3D3D3D;
  426. line-height: 34rpx;
  427. text-align: right;
  428. margin: 20rpx 60rpx 0 0;
  429. >text {
  430. font-size: 24rpx;
  431. color: #FF0000;
  432. line-height: 34rpx;
  433. text-align: right;
  434. }
  435. }
  436. .list {
  437. width: 690rpx;
  438. margin: 20rpx 30rpx 0;
  439. background: #FFFFFF;
  440. border-radius: 20rpx 20rpx 20rpx 20rpx;
  441. .list-li {
  442. display: flex;
  443. justify-content: space-between;
  444. align-items: center;
  445. padding: 0 30rpx;
  446. box-sizing: border-box;
  447. border-bottom: 1rpx solid #E0E0E0;
  448. >view:nth-of-type(1) {
  449. font-size: 30rpx;
  450. color: #333333;
  451. line-height: 80rpx;
  452. text-align: left;
  453. }
  454. >view:nth-of-type(2) {
  455. font-size: 28rpx;
  456. color: #666666;
  457. line-height: 80rpx;
  458. text-align: left;
  459. display: flex;
  460. justify-content: space-between;
  461. align-items: center;
  462. >img {
  463. width: 24rpx;
  464. height: 12rpx;
  465. margin-left: 10rpx;
  466. }
  467. }
  468. }
  469. .hidden-content {
  470. width: 630rpx;
  471. min-height: 200rpx;
  472. background: #F5F5F5;
  473. border-radius: 20rpx 20rpx 20rpx 20rpx;
  474. margin: 20rpx 30rpx 0;
  475. padding: 20rpx;
  476. box-sizing: border-box;
  477. font-size: 28rpx;
  478. color: #666666;
  479. line-height: 39rpx;
  480. text-align: left;
  481. }
  482. .photo {
  483. display: flex;
  484. justify-content: flex-start;
  485. flex-wrap: wrap;
  486. margin-top: 20rpx;
  487. padding: 0 30rpx;
  488. box-sizing: border-box;
  489. >img {
  490. width: 150rpx;
  491. height: 150rpx;
  492. border-radius: 10rpx 10rpx 10rpx 10rpx;
  493. margin: 0 10rpx 10rpx 0;
  494. }
  495. }
  496. .describe {
  497. width: 636rpx;
  498. height: 120rpx;
  499. border-radius: 10rpx 10rpx 10rpx 10rpx;
  500. border: 1rpx solid #E0E0E0;
  501. margin: 20rpx 0 0 28rpx;
  502. padding: 12rpx 16rpx;
  503. box-sizing: border-box;
  504. }
  505. .check-for-img-max-box {
  506. margin: 20px 28rpx;
  507. .left-title-p {
  508. width: 100%;
  509. text-align: left;
  510. font-size: 30rpx;
  511. font-family: PingFang SC-Medium, PingFang SC;
  512. font-weight: 400;
  513. color: #333333;
  514. line-height: 80rpx;
  515. }
  516. .right-img-box {
  517. .img-box {
  518. display inline-block;
  519. height: 150rpx;
  520. width: 150rpx;
  521. position relative;
  522. margin: 0 14rpx 20rpx 0;
  523. border-radius 10rpx;
  524. overflow hidden;
  525. .img-data {
  526. height: 150rpx;
  527. width: 150rpx;
  528. }
  529. .position-img {
  530. position absolute;
  531. right: 0;
  532. top: 0;
  533. width: 36rpx;
  534. height: 36rpx;
  535. }
  536. }
  537. .img-box:nth-of-type(3n+3) {
  538. margin-right: 0rpx;
  539. }
  540. .add-button {
  541. margin: 0 0rpx 20rpx 0;
  542. border-radius 10rpx;
  543. overflow hidden;
  544. display inline-block;
  545. height: 150rpx;
  546. width: 150rpx;
  547. }
  548. }
  549. }
  550. .list-li:last-of-type {
  551. border: none;
  552. }
  553. }
  554. /* 语音备注 */
  555. .voice {
  556. width: 690rpx;
  557. min-height: 440rpx;
  558. background: #FFFFFF;
  559. border-radius: 20rpx 20rpx 20rpx 20rpx;
  560. margin: 20rpx 30rpx;
  561. padding: 30rpx;
  562. box-sizing: border-box;
  563. .voice_t {
  564. height: 80rpx;
  565. display: flex;
  566. justify-content: space-between;
  567. align-items: center;
  568. .voice_t_l {
  569. font-size: 30rpx;
  570. font-family: PingFang SC-Medium, PingFang SC;
  571. font-weight: 400;
  572. color: #333333;
  573. line-height: 80rpx;
  574. }
  575. .voice_t_r {
  576. width: 170rpx;
  577. height: 50rpx;
  578. }
  579. }
  580. .voice_b {
  581. display flex;
  582. justify-content flex-start;
  583. align-items center;
  584. margin-bottom: 30rpx;
  585. .voice_b_l {
  586. width: 400rpx;
  587. height: 40rpx;
  588. background: #0183FA;
  589. border-radius: 10rpx;
  590. display flex;
  591. justify-content flex-start;
  592. align-items center;
  593. font-size: 24rpx;
  594. color: #FFFFFF;
  595. line-height: 30rpx;
  596. text-align: left;
  597. >img {
  598. width: 20rpx;
  599. height: 20rpx;
  600. margin-left: 16rpx;
  601. margin-right: 20rpx;
  602. }
  603. }
  604. .voice_b_r {
  605. width: 28rpx;
  606. height: 28rpx;
  607. margin-left: 20rpx;
  608. }
  609. }
  610. .voice-btn {
  611. width: 150rpx;
  612. height: 150rpx;
  613. position: relative;
  614. margin: 62rpx 0 0 238rpx;
  615. >img {
  616. width: 150rpx;
  617. height: 150rpx;
  618. position: absolute;
  619. }
  620. >text {
  621. font-size: 24rpx;
  622. color: #999999;
  623. line-height: 30rpx;
  624. text-align: center;
  625. position: absolute;
  626. top: 84rpx;
  627. left: 26rpx;
  628. }
  629. }
  630. }
  631. }
  632. .sub-btn {
  633. display: flex;
  634. justify-content: center;
  635. position: fixed;
  636. left: 30rpx;
  637. bottom: 30rpx;
  638. >view:nth-of-type(1) {
  639. width: 230rpx;
  640. height: 100rpx;
  641. background: #009519;
  642. border-radius: 50rpx 0rpx 0rpx 50rpx;
  643. font-size: 30rpx;
  644. color: #FFFFFF;
  645. line-height: 100rpx;
  646. text-align: center;
  647. }
  648. >view:nth-of-type(2) {
  649. width: 230rpx;
  650. height: 100rpx;
  651. background: #0183FA;
  652. border-radius: 0rpx 0rpx 0rpx 0rpx;
  653. font-size: 30rpx;
  654. color: #FFFFFF;
  655. line-height: 100rpx;
  656. text-align: center;
  657. }
  658. >view:nth-of-type(3) {
  659. width: 230rpx;
  660. height: 100rpx;
  661. background: #FF8C00;
  662. border-radius: 0rpx 50rpx 50rpx 0rpx;
  663. font-size: 30rpx;
  664. color: #FFFFFF;
  665. line-height: 100rpx;
  666. text-align: center;
  667. }
  668. }
  669. </style>