snapshotAdd.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. <!-- 随手拍-添加 -->
  2. <template>
  3. <view class="examine">
  4. <view class="header" @click="handleClick('manage')">
  5. <text>随手拍管理</text>
  6. <img src="@/pages_safetyExamine/images/icon_04.png">
  7. </view>
  8. <scroll-view scroll-y @scrolltolower="scrollGet" class="info-max-box">
  9. <view class="basics">
  10. <view class="basics_li">
  11. <view class="basics_li_l">学院</view>
  12. <picker @change="collegeChange" :value="collegeIndex" :range="collegeArray" class="scope_r">
  13. <view class="basics_li_r college_r">
  14. <view>{{form.deptName?form.deptName:'选择学院'}}</view>
  15. <img src="@/pages_safetyExamine/images/icon_06.png">
  16. </view>
  17. </picker>
  18. </view>
  19. <view class="basics_li">
  20. <view class="basics_li_l">实验室</view>
  21. <view class="basics_li_r lab_r">
  22. <input class="picker-text" @click="popupClick(1)" type="text" disabled v-model="form.subName"
  23. placeholder="请输入实验室关键词查询" placeholder-style="font-size: 30rpx;color:#333;">
  24. <view class="img-box" @click.stop="saoCode">
  25. <img src="@/pages_safetyExamine/images/icon_aqjc_sm.png">
  26. </view>
  27. </view>
  28. </view>
  29. <view class="check-for-input-max-box">
  30. <view class="left-title-p">隐患描述:</view>
  31. <textarea type="text" v-model="form.hazardDescribe" maxlength="50" placeholder="请输入隐患描述"
  32. placeholder-style="font-size:28rpx;color:#999;"></textarea>
  33. </view>
  34. <view class="check-for-img-max-box">
  35. <view class="left-title-p">隐患照片(最多上传5张):</view>
  36. <view class="right-img-box">
  37. <view class="img-box" v-for="(imgUrl,imgIndex) in form.imgDtoList" :key="imgIndex">
  38. <img class="img-data" :src="configURL+imgUrl.fileUrl">
  39. <img class="position-img" src="@/pages_safetyExamine/images/icon_ssp_closure.png"
  40. @click="delImg(imgIndex)">
  41. </view>
  42. <img class="add-button" src="@/pages_safetyExamine/images/icon_07.png" @click="selectImage()"
  43. v-if="form.imgDtoList.length<5">
  44. </view>
  45. </view>
  46. </view>
  47. <view class="record"><text @click="handleClick('self')">随手拍上报记录</text></view>
  48. </scroll-view>
  49. <!-- 房间选择弹出层 -->
  50. <view class="popup-max-box" v-if="popupType">
  51. <view class="popup-null" @click="popupClick(2)"></view>
  52. <view class="popup-big-box">
  53. <view class="popup-input-box">
  54. <input type="text" maxlength="10" v-model="room" placeholder="请输入关键字">
  55. <view @click="buildBySub">搜索</view>
  56. </view>
  57. <view class="popup-for-max-box">
  58. <view class="popup-for-null" v-if="!roomList[0]">暂无数据</view>
  59. <view class="popup-for-box" v-for="(item,index) in roomList" :key="index">
  60. <view class="name-p">{{item.subName}} ({{item.roomNum?item.roomNum:'-'}})</view>
  61. <view class="button-p" @click="popupClickItem(item)">确定</view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="bottom_btn" @click="submitForm()">提交</view>
  67. </view>
  68. </template>
  69. <script>
  70. import {
  71. config
  72. } from '@/api/request/config.js'
  73. import {
  74. laboratorySubRelInfoGetRelList,
  75. getUserCollegCheck,
  76. systemDeptDropList,
  77. checkClapAdd,
  78. } from '@/pages_safetyExamine/api/index.js'
  79. export default {
  80. name: "rectifyList",
  81. components: {
  82. },
  83. data() {
  84. return {
  85. configURL: config.base_url,
  86. pageType: 0,
  87. //列表请求参数
  88. getData: {
  89. pageNum: 1,
  90. pageSize: 20,
  91. },
  92. form: {
  93. deptId: '',
  94. deptName: '',
  95. subId: '',
  96. subName: '',
  97. hazardDescribe: '',
  98. imgDtoList: [],
  99. },
  100. collegeIndex: 0,
  101. collegeArray: [],
  102. categoryIndex: 0,
  103. collegeList: [],
  104. categoryArray: ['校级巡查', '院级巡查'],
  105. planIndex: 0,
  106. planArray: ['请选择巡查计划标题', '2023年3月份校级督导检查', '2023年4月份校级督导检查'],
  107. resultIndex: 0,
  108. resultArray: ['不符合', '符合'],
  109. informIndex: 0,
  110. informArray: ['整改告知书', '整改通知书'],
  111. //房间弹层 状态
  112. popupType: false,
  113. //房间搜索字段
  114. room: "",
  115. roomList: [],
  116. }
  117. },
  118. onLoad(option) {
  119. },
  120. onShow() {
  121. },
  122. mounted() {
  123. this.listDepartments();
  124. // this.getUserCollegCheck();
  125. },
  126. methods: {
  127. //滚动事件
  128. scrollGet() {},
  129. handleClick(doType) {
  130. let self = this;
  131. if (doType == 'manage') { //随手拍管理
  132. uni.navigateTo({
  133. url: '/pages_safetyExamine/views/snapshotManage/snapshotList?pageType=1'
  134. });
  135. } else if (doType == 'self') { //随手拍上报记录
  136. uni.navigateTo({
  137. url: '/pages_safetyExamine/views/snapshotManage/snapshotList?pageType=2'
  138. });
  139. } else if (doType == 'subBtn') { //提交
  140. }
  141. },
  142. collegeChange(e) {
  143. this.collegeIndex = e.target.value;
  144. this.form.deptId = this.collegeList[e.target.value].deptId
  145. this.form.deptName = this.collegeList[e.target.value].deptName
  146. },
  147. // 图片上传
  148. selectImage() {
  149. let self = this;
  150. if (this.form.imgDtoList.length > 4) {
  151. uni.showToast({
  152. title: '最多上传5张图片',
  153. icon: "none",
  154. mask: true,
  155. duration: 2000
  156. });
  157. return
  158. }
  159. wx.chooseImage({
  160. count: 5,
  161. sizeType: ["original", "compressed"],
  162. sourceType: ["album", "camera"],
  163. success: function(res) {
  164. //let tempFilePaths = res.tempFilePaths[0];
  165. self.uploadImg(res.tempFilePaths);
  166. }
  167. });
  168. },
  169. async uploadImg(tempFilePaths) {
  170. var self = this;
  171. uni.showLoading({
  172. title: '上传中',
  173. mask: true
  174. });
  175. for (let i = 0; i < tempFilePaths.length; i++) {
  176. console.log(tempFilePaths[i])
  177. uni.uploadFile({
  178. url: config.base_url + '/system/file/upload', //仅为示例,非真实的接口地址
  179. header: {
  180. 'Authorization': uni.getStorageSync('token')
  181. },
  182. filePath: tempFilePaths[i],
  183. name: 'file',
  184. formData: {
  185. 'user': 'test'
  186. },
  187. success: (uploadFileRes) => {
  188. let res = JSON.parse(uploadFileRes.data);
  189. console.log(res.data)
  190. if (res.code == 200) {
  191. this.form.imgDtoList.push({
  192. 'fileUrl': res.data.url,
  193. 'fileName': res.data.name
  194. });
  195. } else {
  196. uni.showToast({
  197. title: res.msg,
  198. icon: "none",
  199. mask: true,
  200. duration: 2000
  201. });
  202. }
  203. },
  204. fail: err => {},
  205. complete: () => {
  206. uni.hideLoading()
  207. }
  208. });
  209. }
  210. },
  211. //删除图片
  212. delImg(minIndex) {
  213. this.form.imgDtoList.splice(minIndex, 1);
  214. this.$forceUpdate();
  215. },
  216. //搜索房间弹层开关
  217. popupClick(type) {
  218. if (type == 1) {
  219. this.room = "";
  220. this.roomList = [];
  221. this.popupType = true;
  222. this.buildBySub();
  223. } else if (type == 2) {
  224. this.popupType = false;
  225. }
  226. },
  227. //搜索房间接口
  228. async buildBySub() {
  229. let self = this;
  230. const {
  231. data
  232. } = await laboratorySubRelInfoGetRelList({
  233. 'searchValue': this.room,
  234. 'deptId': this.form.deptId
  235. });
  236. if (data.code == 200) {
  237. if (data.data[0]) {
  238. this.roomList = data.data;
  239. } else {
  240. uni.showToast({
  241. title: '未找到相关实验室',
  242. icon: "none",
  243. mask: true,
  244. duration: 2000
  245. });
  246. }
  247. }
  248. },
  249. //确认搜索房间
  250. popupClickItem(item) {
  251. console.log(item)
  252. this.$set(this.form, "subId", item.subId)
  253. this.$set(this.form, "subName", item.subName)
  254. this.$set(this.form, "deptId", item.deptId)
  255. for (let i = 0; i < this.collegeList.length; i++) {
  256. if (item.deptId == this.collegeList[i].deptId) {
  257. this.$set(this.form, "deptName", this.collegeList[i].deptName)
  258. }
  259. }
  260. this.popupType = false;
  261. },
  262. //调用摄像头
  263. saoCode() {
  264. let self = this;
  265. uni.scanCode({
  266. onlyFromCamera: true,
  267. success: function(res) {
  268. if (res.result.indexOf("code") != -1 && res.result.indexOf("-") != -1 && res.result
  269. .indexOf("&") != -1) {
  270. let codeRoom = "";
  271. let newList = res.result.split("?")[1].split("&")
  272. let list = newList[0].split("=")[1].split("-")
  273. codeRoom = list[1];
  274. if (codeRoom) {
  275. self.roomList = [];
  276. self.room = codeRoom;
  277. self.buildBySub();
  278. self.popupType = true;
  279. } else {
  280. uni.showToast({
  281. title: '请扫描正确的二维码',
  282. icon: "none",
  283. mask: true,
  284. duration: 2000
  285. });
  286. }
  287. } else {
  288. uni.showToast({
  289. title: '请扫描正确的二维码',
  290. icon: "none",
  291. mask: true,
  292. duration: 2000
  293. });
  294. }
  295. }
  296. });
  297. },
  298. //查询用户身份信息
  299. async getUserCollegCheck() {
  300. let _this = this;
  301. const {
  302. data
  303. } = await getUserCollegCheck();
  304. if (data.code == 200) {
  305. this.form.deptId = data.data.dept.deptId;
  306. this.form.deptName = data.data.dept.deptName;
  307. }
  308. },
  309. //查询学院列表
  310. async listDepartments() {
  311. let self = this;
  312. const {
  313. data
  314. } = await systemDeptDropList({
  315. deptName: '',
  316. level: 2,
  317. deptType: 1
  318. });
  319. if (data.code == 200) {
  320. for (let i = 0; i < data.data.length; i++) {
  321. self.collegeArray.push(data.data[i].deptName)
  322. }
  323. self.collegeList = data.data;
  324. }
  325. },
  326. //添加
  327. async submitForm() {
  328. let _this = this;
  329. if (!this.form.deptId) {
  330. uni.showToast({
  331. title: '请选择学院!',
  332. icon: "none",
  333. mask: true,
  334. duration: 2000
  335. });
  336. return
  337. }
  338. if (!this.form.subId) {
  339. uni.showToast({
  340. title: '请选择实验室!',
  341. icon: "none",
  342. mask: true,
  343. duration: 2000
  344. });
  345. return
  346. }
  347. if (this.form.imgDtoList.length == 0) {
  348. uni.showToast({
  349. title: '请上传隐患照片!',
  350. icon: "none",
  351. mask: true,
  352. duration: 2000
  353. });
  354. return
  355. }
  356. const {
  357. data
  358. } = await checkClapAdd(_this.form);
  359. if (data.code == 200) {
  360. uni.showToast({
  361. title: '提交成功',
  362. icon: "none",
  363. mask: true,
  364. duration: 2000
  365. });
  366. uni.navigateTo({
  367. url: '/pages_safetyExamine/views/snapshotManage/snapshotList?pageType=2'
  368. });
  369. }
  370. },
  371. }
  372. }
  373. </script>
  374. <style lang="stylus" scoped>
  375. .examine {
  376. height: 100%;
  377. display flex;
  378. box-sizing: border-box;
  379. .info-max-box {
  380. flex: 1;
  381. overflow: scroll;
  382. padding: 120rpx 0rpx 128rpx;
  383. box-sizing: border-box;
  384. }
  385. .header {
  386. width: 749rpx;
  387. height: 100rpx;
  388. background: #FFFFFF;
  389. padding: 0 40rpx 0 30rpx;
  390. box-sizing: border-box;
  391. display: flex;
  392. justify-content: space-between;
  393. align-items: center;
  394. position: fixed;
  395. left: 0;
  396. top: 0;
  397. >text {
  398. font-size: 30rpx;
  399. font-family: PingFang SC-Medium, PingFang SC;
  400. font-weight: 400;
  401. color: #333333;
  402. line-height: 42rpx;
  403. }
  404. >img {
  405. width: 8rpx;
  406. height: 14rpx;
  407. }
  408. }
  409. .basics {
  410. margin: 0 30rpx;
  411. width: 690rpx;
  412. background: #FFFFFF;
  413. border-radius: 20rpx;
  414. padding: 30rpx 28rpx 30rpx;
  415. box-sizing: border-box;
  416. .basics_li {
  417. display: flex;
  418. justify-content: flex-start;
  419. margin-bottom: 24rpx;
  420. .basics_li_l {
  421. width: 146rpx;
  422. text-align: left;
  423. font-size: 30rpx;
  424. font-family: PingFang SC-Medium, PingFang SC;
  425. font-weight: 400;
  426. color: #333333;
  427. line-height: 80rpx;
  428. }
  429. .basics_li_r {
  430. width: 486rpx;
  431. height: 80rpx;
  432. border-radius: 10rpx;
  433. opacity: 1;
  434. border: 1rpx solid #E0E0E0;
  435. padding-left: 20rpx;
  436. box-sizing: border-box;
  437. }
  438. /* 学院 */
  439. .college_r {
  440. width: 486rpx;
  441. height: 80rpx;
  442. border-radius: 10rpx;
  443. border: 1rpx solid #E0E0E0;
  444. display: flex;
  445. justify-content: flex-start;
  446. align-items: center;
  447. >view {
  448. flex: 1;
  449. line-height: 80rpx;
  450. font-size: 30rpx;
  451. font-family: PingFang SC-Medium, PingFang SC;
  452. font-weight: 400;
  453. color: #333333;
  454. line-height: 80rpx;
  455. }
  456. >img {
  457. width: 14rpx;
  458. height: 8rpx;
  459. margin-right: 30rpx;
  460. }
  461. }
  462. /* 实验室 */
  463. .lab_r {
  464. width: 486rpx;
  465. height: 80rpx;
  466. display: flex;
  467. justify-content: flex-start;
  468. .picker-text {
  469. width: 438rpx;
  470. height: 80rpx;
  471. }
  472. .img-box {
  473. width: 48rpx;
  474. >img {
  475. width: 30rpx;
  476. height: 28rpx;
  477. margin: 26rpx 18rpx 0 0;
  478. }
  479. }
  480. }
  481. }
  482. /* 隐患描述 */
  483. .check-for-input-max-box {
  484. .left-title-p {
  485. width: 150rpx;
  486. line-height: 80rpx;
  487. text-align right;
  488. font-size: 30rpx;
  489. }
  490. textarea {
  491. width: 630rpx;
  492. height: 158rpx;
  493. border-radius: 20rpx 20rpx 20rpx 20rpx;
  494. border: 1rpx solid #E0E0E0;
  495. padding: 20rpx 14rpx;
  496. box-sizing: border-box;
  497. font-size: 30rpx;
  498. font-family: PingFang SC-Medium, PingFang SC;
  499. font-weight: 400;
  500. color: #333333;
  501. line-height: 34rpx;
  502. }
  503. }
  504. /* 隐患照片 */
  505. .check-for-img-max-box {
  506. .left-title-p {
  507. width: 100%;
  508. text-align: left;
  509. font-size: 30rpx;
  510. font-family: PingFang SC-Medium, PingFang SC;
  511. font-weight: 400;
  512. color: #333333;
  513. line-height: 80rpx;
  514. }
  515. .right-img-box {
  516. .img-box {
  517. display inline-block;
  518. height: 200rpx;
  519. width: 200rpx;
  520. position relative;
  521. margin: 0 14rpx 20rpx 0;
  522. border-radius 10rpx;
  523. overflow hidden;
  524. .img-data {
  525. height: 200rpx;
  526. width: 200rpx;
  527. }
  528. .position-img {
  529. position absolute;
  530. right: 0;
  531. top: 0;
  532. width: 36rpx;
  533. height: 36rpx;
  534. }
  535. }
  536. .img-box:nth-of-type(3n+3) {
  537. margin-right: 0rpx;
  538. }
  539. .add-button {
  540. margin: 0 0rpx 20rpx 0;
  541. border-radius 10rpx;
  542. overflow hidden;
  543. display inline-block;
  544. height: 200rpx;
  545. width: 200rpx;
  546. }
  547. }
  548. }
  549. }
  550. .record {
  551. overflow: hidden;
  552. >text {
  553. display: block;
  554. width: 220rpx;
  555. height: 40rpx;
  556. background: #E0E0E0;
  557. border-radius: 60rpx 60rpx 60rpx 60rpx;
  558. margin: 122rpx 0 90rpx 266rpx;
  559. font-size: 26rpx;
  560. font-family: PingFang SC-Medium, PingFang SC;
  561. font-weight: 400;
  562. color: #0183FA;
  563. line-height: 40rpx;
  564. text-align: center;
  565. }
  566. }
  567. .popup-max-box {
  568. z-index: 10;
  569. height: 100%;
  570. width: 100%;
  571. position fixed;
  572. background rgba(0, 0, 0, 0.2);
  573. display flex;
  574. flex-direction column;
  575. .popup-null {
  576. flex: 1;
  577. }
  578. .popup-big-box {
  579. border-top-left-radius: 20rpx;
  580. border-top-right-radius: 20rpx;
  581. background #fff;
  582. .popup-input-box {
  583. padding: 30rpx 20rpx;
  584. display: flex;
  585. input {
  586. flex: 1;
  587. height: 70rpx;
  588. border: 1rpx solid #e0e0e0;
  589. border-radius: 10rpx;
  590. margin-right: 20rpx;
  591. padding: 0 20rpx;
  592. }
  593. view {
  594. background #0183FA;
  595. color: #fff;
  596. border-radius: 10rpx;
  597. width: 140rpx;
  598. line-height: 70rpx;
  599. text-align center;
  600. font-size: 28rpx;
  601. }
  602. }
  603. .popup-for-max-box {
  604. margin: 0 20rpx 30rpx;
  605. height: 600rpx;
  606. overflow-y scroll;
  607. .popup-for-null {
  608. line-height: 100rpx;
  609. text-align center;
  610. color: #999;
  611. }
  612. .popup-for-box {
  613. display: flex;
  614. padding: 10px 0;
  615. .name-p {
  616. flex: 1;
  617. line-height: 60rpx;
  618. }
  619. .button-p {
  620. background #0183FA;
  621. color: #fff;
  622. text-align center;
  623. width: 100rpx;
  624. line-height: 60rpx;
  625. height: 60rpx;
  626. border-radius: 10rpx;
  627. }
  628. }
  629. }
  630. }
  631. }
  632. .bottom_btn {
  633. position: fixed;
  634. bottom: 26rpx;
  635. left: 30rpx;
  636. font-size: 30rpx;
  637. font-family: PingFang SC-Medium, PingFang SC;
  638. font-weight: 400;
  639. color: #FFFFFF;
  640. line-height: 90rpx;
  641. width: 690rpx;
  642. height: 90rpx;
  643. background: #0183FA;
  644. border-radius: 20rpx;
  645. text-align: center;
  646. }
  647. }
  648. </style>