snapshotAdd.vue 16 KB

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